mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-08-19 12:16:26 +00:00
Refactor systemstatsmonitor/metric_helper.go into a metrics package
This commit is contained in:
@@ -27,7 +27,9 @@ import (
|
||||
"go.opencensus.io/stats"
|
||||
"go.opencensus.io/stats/view"
|
||||
"go.opencensus.io/tag"
|
||||
|
||||
ssmtypes "k8s.io/node-problem-detector/pkg/systemstatsmonitor/types"
|
||||
"k8s.io/node-problem-detector/pkg/util/metrics"
|
||||
)
|
||||
|
||||
type diskCollector struct {
|
||||
@@ -46,21 +48,21 @@ func NewDiskCollectorOrDie(diskConfig *ssmtypes.DiskStatsConfig) *diskCollector
|
||||
dc := diskCollector{config: diskConfig}
|
||||
dc.keyDevice, _ = tag.NewKey("device")
|
||||
|
||||
dc.mIOTime = newInt64Metric(
|
||||
dc.mIOTime = metrics.NewInt64Metric(
|
||||
diskConfig.MetricsConfigs["disk/io_time"].DisplayName,
|
||||
"The IO time spent on the disk",
|
||||
"second",
|
||||
view.LastValue(),
|
||||
[]tag.Key{dc.keyDevice})
|
||||
|
||||
dc.mWeightedIO = newInt64Metric(
|
||||
dc.mWeightedIO = metrics.NewInt64Metric(
|
||||
diskConfig.MetricsConfigs["disk/weighted_io"].DisplayName,
|
||||
"The weighted IO on the disk",
|
||||
"second",
|
||||
view.LastValue(),
|
||||
[]tag.Key{dc.keyDevice})
|
||||
|
||||
dc.mAvgQueueLen = newFloat64Metric(
|
||||
dc.mAvgQueueLen = metrics.NewFloat64Metric(
|
||||
diskConfig.MetricsConfigs["disk/avg_queue_len"].DisplayName,
|
||||
"The average queue length on the disk",
|
||||
"second",
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"k8s.io/node-problem-detector/pkg/problemdaemon"
|
||||
ssmtypes "k8s.io/node-problem-detector/pkg/systemstatsmonitor/types"
|
||||
"k8s.io/node-problem-detector/pkg/types"
|
||||
|
||||
@@ -13,8 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package systemstatsmonitor
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"go.opencensus.io/stats"
|
||||
@@ -22,8 +21,8 @@ import (
|
||||
"go.opencensus.io/tag"
|
||||
)
|
||||
|
||||
// newInt64Metric create a stats.Int64 metrics, returns nil when name is empty.
|
||||
func newInt64Metric(name string, description string, unit string, aggregation *view.Aggregation, tagKeys []tag.Key) *stats.Int64Measure {
|
||||
// NewInt64Metric create a stats.Int64 metrics, returns nil when name is empty.
|
||||
func NewInt64Metric(name string, description string, unit string, aggregation *view.Aggregation, tagKeys []tag.Key) *stats.Int64Measure {
|
||||
if name == "" {
|
||||
return nil
|
||||
}
|
||||
@@ -39,8 +38,8 @@ func newInt64Metric(name string, description string, unit string, aggregation *v
|
||||
return measure
|
||||
}
|
||||
|
||||
// newFloat64Metric create a stats.Float64 metrics, returns nil when name is empty.
|
||||
func newFloat64Metric(name string, description string, unit string, aggregation *view.Aggregation, tagKeys []tag.Key) *stats.Float64Measure {
|
||||
// NewFloat64Metric create a stats.Float64 metrics, returns nil when name is empty.
|
||||
func NewFloat64Metric(name string, description string, unit string, aggregation *view.Aggregation, tagKeys []tag.Key) *stats.Float64Measure {
|
||||
if name == "" {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user