Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename host metrics to more consistent names based on OTEP #1261

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions receiver/hostmetricsreceiver/hostmetrics_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,36 @@ import (
)

var standardMetrics = []string{
"host/cpu/usage",
"host/memory/used",
"host/disk/bytes",
"host/disk/ops",
"host/disk/time",
"host/filesystem/used",
"host/load/1m",
"host/load/5m",
"host/load/15m",
"host/network/packets",
"host/network/dropped_packets",
"host/network/errors",
"host/network/bytes",
"host/network/tcp_connections",
"host/swap/paging",
"host/swap/usage",
"system.cpu.time",
"system.memory.usage",
"system.disk.io",
"system.disk.ops",
"system.disk.time",
"system.filesystem.usage",
"system.cpu.load_average.1m",
"system.cpu.load_average.5m",
"system.cpu.load_average.15m",
"system.network.packets",
"system.network.dropped_packets",
"system.network.errors",
"system.network.io",
"system.network.tcp_connections",
"system.swap.paging_ops",
"system.swap.usage",
}

var resourceMetrics = []string{
"process/cpu/usage",
"process/memory/usage",
"process/disk/bytes",
"process.cpu.time",
"process.memory.usage",
"process.disk.io",
}

var systemSpecificMetrics = map[string][]string{
"linux": {"host/filesystem/inodes/used", "host/swap/page_faults"},
"darwin": {"host/filesystem/inodes/used", "host/swap/page_faults"},
"freebsd": {"host/filesystem/inodes/used", "host/swap/page_faults"},
"openbsd": {"host/filesystem/inodes/used", "host/swap/page_faults"},
"solaris": {"host/filesystem/inodes/used", "host/swap/page_faults"},
"linux": {"system.filesystem.inodes.usage", "system.swap.page_faults"},
"darwin": {"system.filesystem.inodes.usage", "system.swap.page_faults"},
"freebsd": {"system.filesystem.inodes.usage", "system.swap.page_faults"},
"openbsd": {"system.filesystem.inodes.usage", "system.swap.page_faults"},
"solaris": {"system.filesystem.inodes.usage", "system.swap.page_faults"},
}

var factories = map[string]internal.ScraperFactory{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ const (

// descriptors

var metricCPUSecondsDescriptor = createMetricCPUSecondsDescriptor()

func createMetricCPUSecondsDescriptor() pdata.MetricDescriptor {
var cpuTimeDescriptor = func() pdata.MetricDescriptor {
descriptor := pdata.NewMetricDescriptor()
descriptor.InitEmpty()
descriptor.SetName("host/cpu/usage")
descriptor.SetName("system.cpu.time")
descriptor.SetDescription("Total CPU seconds broken down by different states.")
descriptor.SetUnit("s")
descriptor.SetType(pdata.MetricTypeMonotonicDouble)
return descriptor
}
}()
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,23 @@ func (s *scraper) ScrapeMetrics(ctx context.Context) (pdata.MetricSlice, error)
}

metrics.Resize(1)
initializeCPUSecondsMetric(metrics.At(0), s.startTime, cpuTimes)
initializeCPUTimeMetric(metrics.At(0), s.startTime, cpuTimes)
return metrics, nil
}

func initializeCPUSecondsMetric(metric pdata.Metric, startTime pdata.TimestampUnixNano, cpuTimes []cpu.TimesStat) {
metricCPUSecondsDescriptor.CopyTo(metric.MetricDescriptor())
func initializeCPUTimeMetric(metric pdata.Metric, startTime pdata.TimestampUnixNano, cpuTimes []cpu.TimesStat) {
cpuTimeDescriptor.CopyTo(metric.MetricDescriptor())

ddps := metric.DoubleDataPoints()
ddps.Resize(len(cpuTimes) * cpuStatesLen)
for i, cpuTime := range cpuTimes {
appendCPUStateTimes(ddps, i*cpuStatesLen, startTime, cpuTime)
appendCPUTimeStateDataPoints(ddps, i*cpuStatesLen, startTime, cpuTime)
}
}

const gopsCPUTotal string = "cpu-total"

func initializeCPUSecondsDataPoint(dataPoint pdata.DoubleDataPoint, startTime pdata.TimestampUnixNano, cpuLabel string, stateLabel string, value float64) {
func initializeCPUTimeDataPoint(dataPoint pdata.DoubleDataPoint, startTime pdata.TimestampUnixNano, cpuLabel string, stateLabel string, value float64) {
labelsMap := dataPoint.LabelsMap()
// ignore cpu label if reporting "total" cpu usage
if cpuLabel != gopsCPUTotal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import (

const cpuStatesLen = 8

func appendCPUStateTimes(ddps pdata.DoubleDataPointSlice, startIdx int, startTime pdata.TimestampUnixNano, cpuTime cpu.TimesStat) {
initializeCPUSecondsDataPoint(ddps.At(startIdx+0), startTime, cpuTime.CPU, userStateLabelValue, cpuTime.User)
initializeCPUSecondsDataPoint(ddps.At(startIdx+1), startTime, cpuTime.CPU, systemStateLabelValue, cpuTime.System)
initializeCPUSecondsDataPoint(ddps.At(startIdx+2), startTime, cpuTime.CPU, idleStateLabelValue, cpuTime.Idle)
initializeCPUSecondsDataPoint(ddps.At(startIdx+3), startTime, cpuTime.CPU, interruptStateLabelValue, cpuTime.Irq)
initializeCPUSecondsDataPoint(ddps.At(startIdx+4), startTime, cpuTime.CPU, niceStateLabelValue, cpuTime.Nice)
initializeCPUSecondsDataPoint(ddps.At(startIdx+5), startTime, cpuTime.CPU, softIRQStateLabelValue, cpuTime.Softirq)
initializeCPUSecondsDataPoint(ddps.At(startIdx+6), startTime, cpuTime.CPU, stealStateLabelValue, cpuTime.Steal)
initializeCPUSecondsDataPoint(ddps.At(startIdx+7), startTime, cpuTime.CPU, waitStateLabelValue, cpuTime.Iowait)
func appendCPUTimeStateDataPoints(ddps pdata.DoubleDataPointSlice, startIdx int, startTime pdata.TimestampUnixNano, cpuTime cpu.TimesStat) {
initializeCPUTimeDataPoint(ddps.At(startIdx+0), startTime, cpuTime.CPU, userStateLabelValue, cpuTime.User)
initializeCPUTimeDataPoint(ddps.At(startIdx+1), startTime, cpuTime.CPU, systemStateLabelValue, cpuTime.System)
initializeCPUTimeDataPoint(ddps.At(startIdx+2), startTime, cpuTime.CPU, idleStateLabelValue, cpuTime.Idle)
initializeCPUTimeDataPoint(ddps.At(startIdx+3), startTime, cpuTime.CPU, interruptStateLabelValue, cpuTime.Irq)
initializeCPUTimeDataPoint(ddps.At(startIdx+4), startTime, cpuTime.CPU, niceStateLabelValue, cpuTime.Nice)
initializeCPUTimeDataPoint(ddps.At(startIdx+5), startTime, cpuTime.CPU, softIRQStateLabelValue, cpuTime.Softirq)
initializeCPUTimeDataPoint(ddps.At(startIdx+6), startTime, cpuTime.CPU, stealStateLabelValue, cpuTime.Steal)
initializeCPUTimeDataPoint(ddps.At(startIdx+7), startTime, cpuTime.CPU, waitStateLabelValue, cpuTime.Iowait)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (

const cpuStatesLen = 4

func appendCPUStateTimes(ddps pdata.DoubleDataPointSlice, startIdx int, startTime pdata.TimestampUnixNano, cpuTime cpu.TimesStat) {
initializeCPUSecondsDataPoint(ddps.At(startIdx+0), startTime, cpuTime.CPU, userStateLabelValue, cpuTime.User)
initializeCPUSecondsDataPoint(ddps.At(startIdx+1), startTime, cpuTime.CPU, systemStateLabelValue, cpuTime.System)
initializeCPUSecondsDataPoint(ddps.At(startIdx+2), startTime, cpuTime.CPU, idleStateLabelValue, cpuTime.Idle)
initializeCPUSecondsDataPoint(ddps.At(startIdx+3), startTime, cpuTime.CPU, interruptStateLabelValue, cpuTime.Irq)
func appendCPUTimeStateDataPoints(ddps pdata.DoubleDataPointSlice, startIdx int, startTime pdata.TimestampUnixNano, cpuTime cpu.TimesStat) {
initializeCPUTimeDataPoint(ddps.At(startIdx+0), startTime, cpuTime.CPU, userStateLabelValue, cpuTime.User)
initializeCPUTimeDataPoint(ddps.At(startIdx+1), startTime, cpuTime.CPU, systemStateLabelValue, cpuTime.System)
initializeCPUTimeDataPoint(ddps.At(startIdx+2), startTime, cpuTime.CPU, idleStateLabelValue, cpuTime.Idle)
initializeCPUTimeDataPoint(ddps.At(startIdx+3), startTime, cpuTime.CPU, interruptStateLabelValue, cpuTime.Irq)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func TestScrapeMetrics_MinimalData(t *testing.T) {
assert.Equal(t, 1, metrics.Len())

// for cpu seconds metric, expect a datapoint for each state label, including at least 4 standard states
hostCPUTimeMetric := metrics.At(0)
internal.AssertDescriptorEqual(t, metricCPUSecondsDescriptor, hostCPUTimeMetric.MetricDescriptor())
assert.GreaterOrEqual(t, hostCPUTimeMetric.DoubleDataPoints().Len(), 4)
internal.AssertDoubleMetricLabelDoesNotExist(t, hostCPUTimeMetric, 0, cpuLabelName)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 0, stateLabelName, userStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 1, stateLabelName, systemStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 2, stateLabelName, idleStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 3, stateLabelName, interruptStateLabelValue)
cpuTimeMetric := metrics.At(0)
internal.AssertDescriptorEqual(t, cpuTimeDescriptor, cpuTimeMetric.MetricDescriptor())
assert.GreaterOrEqual(t, cpuTimeMetric.DoubleDataPoints().Len(), 4)
internal.AssertDoubleMetricLabelDoesNotExist(t, cpuTimeMetric, 0, cpuLabelName)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 0, stateLabelName, userStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 1, stateLabelName, systemStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 2, stateLabelName, idleStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 3, stateLabelName, interruptStateLabelValue)
})
}

Expand All @@ -55,14 +55,14 @@ func TestScrapeMetrics_AllData(t *testing.T) {
assert.Equal(t, 1, metrics.Len())

// for cpu seconds metric, expect a datapoint for each state label & core combination with at least 4 standard states
hostCPUTimeMetric := metrics.At(0)
internal.AssertDescriptorEqual(t, metricCPUSecondsDescriptor, hostCPUTimeMetric.MetricDescriptor())
assert.GreaterOrEqual(t, hostCPUTimeMetric.DoubleDataPoints().Len(), runtime.NumCPU()*4)
internal.AssertDoubleMetricLabelExists(t, hostCPUTimeMetric, 0, cpuLabelName)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 0, stateLabelName, userStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 1, stateLabelName, systemStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 2, stateLabelName, idleStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 3, stateLabelName, interruptStateLabelValue)
cpuTimeMetric := metrics.At(0)
internal.AssertDescriptorEqual(t, cpuTimeDescriptor, cpuTimeMetric.MetricDescriptor())
assert.GreaterOrEqual(t, cpuTimeMetric.DoubleDataPoints().Len(), runtime.NumCPU()*4)
internal.AssertDoubleMetricLabelExists(t, cpuTimeMetric, 0, cpuLabelName)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 0, stateLabelName, userStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 1, stateLabelName, systemStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 2, stateLabelName, idleStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 3, stateLabelName, interruptStateLabelValue)
})
}

Expand All @@ -73,18 +73,18 @@ func TestScrapeMetrics_Linux(t *testing.T) {

createScraperAndValidateScrapedMetrics(t, &Config{}, func(t *testing.T, metrics pdata.MetricSlice) {
// for cpu seconds metric, expect a datapoint for all 8 state labels
hostCPUTimeMetric := metrics.At(0)
internal.AssertDescriptorEqual(t, metricCPUSecondsDescriptor, hostCPUTimeMetric.MetricDescriptor())
assert.Equal(t, 8, hostCPUTimeMetric.DoubleDataPoints().Len())
internal.AssertDoubleMetricLabelDoesNotExist(t, hostCPUTimeMetric, 0, cpuLabelName)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 0, stateLabelName, userStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 1, stateLabelName, systemStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 2, stateLabelName, idleStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 3, stateLabelName, interruptStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 4, stateLabelName, niceStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 5, stateLabelName, softIRQStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 6, stateLabelName, stealStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, hostCPUTimeMetric, 7, stateLabelName, waitStateLabelValue)
cpuTimeMetric := metrics.At(0)
internal.AssertDescriptorEqual(t, cpuTimeDescriptor, cpuTimeMetric.MetricDescriptor())
assert.Equal(t, 8, cpuTimeMetric.DoubleDataPoints().Len())
internal.AssertDoubleMetricLabelDoesNotExist(t, cpuTimeMetric, 0, cpuLabelName)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 0, stateLabelName, userStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 1, stateLabelName, systemStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 2, stateLabelName, idleStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 3, stateLabelName, interruptStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 4, stateLabelName, niceStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 5, stateLabelName, softIRQStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 6, stateLabelName, stealStateLabelValue)
internal.AssertDoubleMetricLabelHasValue(t, cpuTimeMetric, 7, stateLabelName, waitStateLabelValue)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,32 @@ const (

// descriptors

var metricDiskBytesDescriptor = createMetricDiskBytesDescriptor()

func createMetricDiskBytesDescriptor() pdata.MetricDescriptor {
var diskIODescriptor = func() pdata.MetricDescriptor {
descriptor := pdata.NewMetricDescriptor()
descriptor.InitEmpty()
descriptor.SetName("host/disk/bytes")
descriptor.SetName("system.disk.io")
descriptor.SetDescription("Disk bytes transferred.")
descriptor.SetUnit("bytes")
descriptor.SetType(pdata.MetricTypeMonotonicInt64)
return descriptor
}

var metricDiskOpsDescriptor = createMetricDiskOpsDescriptor()
}()

func createMetricDiskOpsDescriptor() pdata.MetricDescriptor {
var diskOpsDescriptor = func() pdata.MetricDescriptor {
descriptor := pdata.NewMetricDescriptor()
descriptor.InitEmpty()
descriptor.SetName("host/disk/ops")
descriptor.SetName("system.disk.ops")
descriptor.SetDescription("Disk operations count.")
descriptor.SetUnit("1")
descriptor.SetType(pdata.MetricTypeMonotonicInt64)
return descriptor
}
}()

var metricDiskTimeDescriptor = createMetricDiskTimeDescriptor()

func createMetricDiskTimeDescriptor() pdata.MetricDescriptor {
var diskTimeDescriptor = func() pdata.MetricDescriptor {
descriptor := pdata.NewMetricDescriptor()
descriptor.InitEmpty()
descriptor.SetName("host/disk/time")
descriptor.SetName("system.disk.time")
descriptor.SetDescription("Time spent in disk operations.")
descriptor.SetUnit("ms")
descriptor.SetType(pdata.MetricTypeInt64)
descriptor.SetType(pdata.MetricTypeMonotonicInt64)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was incorrectly a gauge, when it should have been a counter

return descriptor
}
}()
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ func (s *scraper) ScrapeMetrics(ctx context.Context) (pdata.MetricSlice, error)
}

metrics.Resize(3)
initializeMetricDiskBytes(metrics.At(0), ioCounters, s.startTime)
initializeMetricDiskOps(metrics.At(1), ioCounters, s.startTime)
initializeMetricDiskTime(metrics.At(2), ioCounters, s.startTime)
initializeDiskIOMetric(metrics.At(0), ioCounters, s.startTime)
initializeDiskOpsMetric(metrics.At(1), ioCounters, s.startTime)
initializeDiskTimeMetric(metrics.At(2), ioCounters, s.startTime)
return metrics, nil
}

func initializeMetricDiskBytes(metric pdata.Metric, ioCounters map[string]disk.IOCountersStat, startTime pdata.TimestampUnixNano) {
metricDiskBytesDescriptor.CopyTo(metric.MetricDescriptor())
func initializeDiskIOMetric(metric pdata.Metric, ioCounters map[string]disk.IOCountersStat, startTime pdata.TimestampUnixNano) {
diskIODescriptor.CopyTo(metric.MetricDescriptor())

idps := metric.Int64DataPoints()
idps.Resize(2 * len(ioCounters))
Expand All @@ -85,8 +85,8 @@ func initializeMetricDiskBytes(metric pdata.Metric, ioCounters map[string]disk.I
}
}

func initializeMetricDiskOps(metric pdata.Metric, ioCounters map[string]disk.IOCountersStat, startTime pdata.TimestampUnixNano) {
metricDiskOpsDescriptor.CopyTo(metric.MetricDescriptor())
func initializeDiskOpsMetric(metric pdata.Metric, ioCounters map[string]disk.IOCountersStat, startTime pdata.TimestampUnixNano) {
diskOpsDescriptor.CopyTo(metric.MetricDescriptor())

idps := metric.Int64DataPoints()
idps.Resize(2 * len(ioCounters))
Expand All @@ -99,8 +99,8 @@ func initializeMetricDiskOps(metric pdata.Metric, ioCounters map[string]disk.IOC
}
}

func initializeMetricDiskTime(metric pdata.Metric, ioCounters map[string]disk.IOCountersStat, startTime pdata.TimestampUnixNano) {
metricDiskTimeDescriptor.CopyTo(metric.MetricDescriptor())
func initializeDiskTimeMetric(metric pdata.Metric, ioCounters map[string]disk.IOCountersStat, startTime pdata.TimestampUnixNano) {
diskTimeDescriptor.CopyTo(metric.MetricDescriptor())

idps := metric.Int64DataPoints()
idps.Resize(2 * len(ioCounters))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func TestScrapeMetrics(t *testing.T) {
assert.Equal(t, 3, metrics.Len())

// for each disk metric, expect a read & write datapoint for at least one drive
assertDiskMetricMatchesDescriptorAndHasReadAndWriteDataPoints(t, metrics.At(0), metricDiskBytesDescriptor)
assertDiskMetricMatchesDescriptorAndHasReadAndWriteDataPoints(t, metrics.At(1), metricDiskOpsDescriptor)
assertDiskMetricMatchesDescriptorAndHasReadAndWriteDataPoints(t, metrics.At(2), metricDiskTimeDescriptor)
assertDiskMetricMatchesDescriptorAndHasReadAndWriteDataPoints(t, metrics.At(0), diskIODescriptor)
assertDiskMetricMatchesDescriptorAndHasReadAndWriteDataPoints(t, metrics.At(1), diskOpsDescriptor)
assertDiskMetricMatchesDescriptorAndHasReadAndWriteDataPoints(t, metrics.At(2), diskTimeDescriptor)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,22 @@ const (

// descriptors

var metricFilesystemUsedDescriptor = createMetricFilesystemUsedDescriptor()

func createMetricFilesystemUsedDescriptor() pdata.MetricDescriptor {
var fileSystemUsageDescriptor = func() pdata.MetricDescriptor {
descriptor := pdata.NewMetricDescriptor()
descriptor.InitEmpty()
descriptor.SetName("host/filesystem/used")
descriptor.SetName("system.filesystem.usage")
descriptor.SetDescription("Filesystem bytes used.")
descriptor.SetUnit("bytes")
descriptor.SetType(pdata.MetricTypeInt64)
return descriptor
}

var metricFilesystemINodesUsedDescriptor = createMetricFilesystemINodesUsedDescriptor()
}()

func createMetricFilesystemINodesUsedDescriptor() pdata.MetricDescriptor {
var fileSystemINodesUsageDescriptor = func() pdata.MetricDescriptor {
descriptor := pdata.NewMetricDescriptor()
descriptor.InitEmpty()
descriptor.SetName("host/filesystem/inodes/used")
descriptor.SetName("system.filesystem.inodes.usage")
descriptor.SetDescription("FileSystem operations count.")
descriptor.SetUnit("1")
descriptor.SetType(pdata.MetricTypeInt64)
return descriptor
}
}()
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (s *scraper) ScrapeMetrics(ctx context.Context) (pdata.MetricSlice, error)
if len(usages) > 0 {
metrics.Resize(1 + systemSpecificMetricsLen)

initializeMetricFileSystemUsed(metrics.At(0), usages)
initializeFileSystemUsageMetric(metrics.At(0), usages)
appendSystemSpecificMetrics(metrics, 1, usages)
}

Expand All @@ -91,17 +91,17 @@ func (s *scraper) ScrapeMetrics(ctx context.Context) (pdata.MetricSlice, error)
return metrics, nil
}

func initializeMetricFileSystemUsed(metric pdata.Metric, deviceUsages []*deviceUsage) {
metricFilesystemUsedDescriptor.CopyTo(metric.MetricDescriptor())
func initializeFileSystemUsageMetric(metric pdata.Metric, deviceUsages []*deviceUsage) {
fileSystemUsageDescriptor.CopyTo(metric.MetricDescriptor())

idps := metric.Int64DataPoints()
idps.Resize(fileSystemStatesLen * len(deviceUsages))
for i, deviceUsage := range deviceUsages {
appendFileSystemUsedStateDataPoints(idps, i*fileSystemStatesLen, deviceUsage)
appendFileSystemUsageStateDataPoints(idps, i*fileSystemStatesLen, deviceUsage)
}
}

func initializeFileSystemUsedDataPoint(dataPoint pdata.Int64DataPoint, deviceLabel string, stateLabel string, value int64) {
func initializeFileSystemUsageDataPoint(dataPoint pdata.Int64DataPoint, deviceLabel string, stateLabel string, value int64) {
labelsMap := dataPoint.LabelsMap()
labelsMap.Insert(deviceLabelName, deviceLabel)
labelsMap.Insert(stateLabelName, stateLabel)
Expand Down
Loading