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 according to metrics spec #2311

Merged
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ require (
github.com/prometheus/common v0.15.0
github.com/prometheus/prometheus v1.8.2-0.20201105135750-00f16d1ac3a4
github.com/rs/cors v1.7.0
github.com/shirou/gopsutil v3.20.11+incompatible
github.com/shirou/gopsutil v3.20.12-0.20201210134652-afe0c04c5d5a+incompatible
github.com/soheilhy/cmux v0.1.4
github.com/spf13/cast v1.3.1
github.com/spf13/cobra v1.1.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,8 @@ github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfP
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto=
github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v3.20.12-0.20201210134652-afe0c04c5d5a+incompatible h1:uvFOXu1W/nsxgfbLu0jGTad6j0PbFDsXkwxK/rqT/AA=
github.com/shirou/gopsutil v3.20.12-0.20201210134652-afe0c04c5d5a+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
Expand Down
2 changes: 1 addition & 1 deletion receiver/hostmetricsreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ The available scrapers are:
| filesystem | All | File System utilization metrics |
| memory | All | Memory utilization metrics |
| network | All | Network interface I/O metrics & TCP connection metrics |
| paging | All | Paging/Swap space utilization and I/O metrics
| processes | Linux | Process count metrics |
| swap | All | Swap space utilization and I/O metrics |
| process | Linux & Windows | Per process CPU, Memory, and Disk I/O metrics |

### Notes
Expand Down
4 changes: 2 additions & 2 deletions receiver/hostmetricsreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import (
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/loadscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/memoryscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/networkscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/pagingscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/processesscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/processscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/swapscraper"
"go.opentelemetry.io/collector/receiver/scraperhelper"
)

Expand Down Expand Up @@ -82,7 +82,7 @@ func TestLoadConfig(t *testing.T) {
},
},
processesscraper.TypeStr: &processesscraper.Config{},
swapscraper.TypeStr: &swapscraper.Config{},
pagingscraper.TypeStr: &pagingscraper.Config{},
processscraper.TypeStr: &processscraper.Config{
Include: processscraper.MatchConfig{
Names: []string{"test2", "test3"},
Expand Down
2 changes: 1 addition & 1 deletion receiver/hostmetricsreceiver/example_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ receivers:
disk:
filesystem:
network:
paging:
processes:
swap:

exporters:
logging:
Expand Down
4 changes: 2 additions & 2 deletions receiver/hostmetricsreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import (
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/loadscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/memoryscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/networkscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/pagingscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/processesscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/processscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/swapscraper"
"go.opentelemetry.io/collector/receiver/receiverhelper"
"go.opentelemetry.io/collector/receiver/scraperhelper"
)
Expand All @@ -56,8 +56,8 @@ var (
filesystemscraper.TypeStr: &filesystemscraper.Factory{},
memoryscraper.TypeStr: &memoryscraper.Factory{},
networkscraper.TypeStr: &networkscraper.Factory{},
pagingscraper.TypeStr: &pagingscraper.Factory{},
processesscraper.TypeStr: &processesscraper.Factory{},
swapscraper.TypeStr: &swapscraper.Factory{},
}

resourceScraperFactories = map[string]internal.ResourceScraperFactory{
Expand Down
52 changes: 26 additions & 26 deletions receiver/hostmetricsreceiver/hostmetrics_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,31 @@ import (
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/loadscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/memoryscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/networkscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/pagingscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/processesscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/processscraper"
"go.opentelemetry.io/collector/receiver/hostmetricsreceiver/internal/scraper/swapscraper"
"go.opentelemetry.io/collector/receiver/scraperhelper"
)

var standardMetrics = []string{
"system.cpu.time",
"system.memory.usage",
"system.cpu.load_average.1m",
"system.cpu.load_average.5m",
"system.cpu.load_average.15m",
"system.disk.io",
"system.disk.io_time",
"system.disk.ops",
"system.disk.operations",
"system.disk.operation_time",
"system.disk.pending_operations",
"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.memory.usage",
"system.network.connections",
"system.network.dropped",
"system.network.errors",
"system.network.io",
"system.network.tcp_connections",
"system.swap.paging_ops",
"system.swap.usage",
"system.network.packets",
"system.paging.operations",
"system.paging.usage",
}

var resourceMetrics = []string{
Expand All @@ -72,11 +72,11 @@ var resourceMetrics = []string{
}

var systemSpecificMetrics = map[string][]string{
"linux": {"system.disk.merged", "system.filesystem.inodes.usage", "system.processes.running", "system.processes.blocked", "system.swap.page_faults"},
"darwin": {"system.filesystem.inodes.usage", "system.processes.running", "system.processes.blocked", "system.swap.page_faults"},
"freebsd": {"system.filesystem.inodes.usage", "system.processes.running", "system.processes.blocked", "system.swap.page_faults"},
"openbsd": {"system.filesystem.inodes.usage", "system.processes.running", "system.processes.blocked", "system.swap.page_faults"},
"solaris": {"system.filesystem.inodes.usage", "system.swap.page_faults"},
"linux": {"system.disk.merged", "system.filesystem.inodes.usage", "system.paging.faults", "system.processes.created", "system.processes.count"},
"darwin": {"system.filesystem.inodes.usage", "system.paging.faults", "system.processes.count"},
"freebsd": {"system.filesystem.inodes.usage", "system.paging.faults", "system.processes.count"},
"openbsd": {"system.filesystem.inodes.usage", "system.paging.faults", "system.processes.created", "system.processes.count"},
"solaris": {"system.filesystem.inodes.usage", "system.paging.faults"},
}

var factories = map[string]internal.ScraperFactory{
Expand All @@ -86,8 +86,8 @@ var factories = map[string]internal.ScraperFactory{
loadscraper.TypeStr: &loadscraper.Factory{},
memoryscraper.TypeStr: &memoryscraper.Factory{},
networkscraper.TypeStr: &networkscraper.Factory{},
pagingscraper.TypeStr: &pagingscraper.Factory{},
processesscraper.TypeStr: &processesscraper.Factory{},
swapscraper.TypeStr: &swapscraper.Factory{},
}

var resourceFactories = map[string]internal.ResourceScraperFactory{
Expand All @@ -111,8 +111,8 @@ func TestGatherMetrics_EndToEnd(t *testing.T) {
loadscraper.TypeStr: &loadscraper.Config{},
memoryscraper.TypeStr: &memoryscraper.Config{},
networkscraper.TypeStr: &networkscraper.Config{},
pagingscraper.TypeStr: &pagingscraper.Config{},
processesscraper.TypeStr: &processesscraper.Config{},
swapscraper.TypeStr: &swapscraper.Config{},
},
}

Expand Down Expand Up @@ -376,10 +376,10 @@ func Benchmark_ScrapeProcessesMetrics(b *testing.B) {
benchmarkScrapeMetrics(b, cfg)
}

func Benchmark_ScrapeSwapMetrics(b *testing.B) {
func Benchmark_ScrapePagingMetrics(b *testing.B) {
cfg := &Config{
ScraperControllerSettings: scraperhelper.DefaultScraperControllerSettings(""),
Scrapers: map[string]internal.Config{swapscraper.TypeStr: (&swapscraper.Factory{}).CreateDefaultConfig()},
Scrapers: map[string]internal.Config{pagingscraper.TypeStr: (&pagingscraper.Factory{}).CreateDefaultConfig()},
}

benchmarkScrapeMetrics(b, cfg)
Expand Down Expand Up @@ -408,15 +408,19 @@ func Benchmark_ScrapeSystemMetrics(b *testing.B) {
loadscraper.TypeStr: (&loadscraper.Factory{}).CreateDefaultConfig(),
memoryscraper.TypeStr: (&memoryscraper.Factory{}).CreateDefaultConfig(),
networkscraper.TypeStr: (&networkscraper.Factory{}).CreateDefaultConfig(),
pagingscraper.TypeStr: (&pagingscraper.Factory{}).CreateDefaultConfig(),
processesscraper.TypeStr: (&processesscraper.Factory{}).CreateDefaultConfig(),
swapscraper.TypeStr: (&swapscraper.Factory{}).CreateDefaultConfig(),
},
}

benchmarkScrapeMetrics(b, cfg)
}

func Benchmark_ScrapeSystemAndProcessMetrics(b *testing.B) {
if runtime.GOOS != "linux" && runtime.GOOS != "windows" {
b.Skip("skipping test on non linux/windows")
}

cfg := &Config{
ScraperControllerSettings: scraperhelper.DefaultScraperControllerSettings(""),
Scrapers: map[string]internal.Config{
Expand All @@ -426,14 +430,10 @@ func Benchmark_ScrapeSystemAndProcessMetrics(b *testing.B) {
loadscraper.TypeStr: &loadscraper.Config{},
memoryscraper.TypeStr: &memoryscraper.Config{},
networkscraper.TypeStr: &networkscraper.Config{},
pagingscraper.TypeStr: (&pagingscraper.Factory{}).CreateDefaultConfig(),
processesscraper.TypeStr: &processesscraper.Config{},
swapscraper.TypeStr: &swapscraper.Config{},
},
}

if runtime.GOOS == "linux" || runtime.GOOS == "windows" {
cfg.Scrapers[processscraper.TypeStr] = &processscraper.Config{}
}

benchmarkScrapeMetrics(b, cfg)
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ var diskIODescriptor = func() pdata.Metric {
metric := pdata.NewMetric()
metric.SetName("system.disk.io")
metric.SetDescription("Disk bytes transferred.")
metric.SetUnit("bytes")
metric.SetUnit("By")
metric.SetDataType(pdata.MetricDataTypeIntSum)
sum := metric.IntSum()
sum.SetIsMonotonic(true)
sum.SetAggregationTemporality(pdata.AggregationTemporalityCumulative)
return metric
}()

var diskOpsDescriptor = func() pdata.Metric {
var diskOperationsDescriptor = func() pdata.Metric {
metric := pdata.NewMetric()
metric.SetName("system.disk.ops")
metric.SetName("system.disk.operations")
metric.SetDescription("Disk operations count.")
metric.SetUnit("1")
metric.SetUnit("{operations}")
metric.SetDataType(pdata.MetricDataTypeIntSum)
sum := metric.IntSum()
sum.SetIsMonotonic(true)
Expand Down Expand Up @@ -86,7 +86,7 @@ var diskPendingOperationsDescriptor = func() pdata.Metric {
metric := pdata.NewMetric()
metric.SetName("system.disk.pending_operations")
metric.SetDescription("The queue size of pending I/O operations.")
metric.SetUnit("1")
metric.SetUnit("{operations}")
metric.SetDataType(pdata.MetricDataTypeIntSum)
sum := metric.IntSum()
sum.SetIsMonotonic(false)
Expand All @@ -98,7 +98,7 @@ var diskMergedDescriptor = func() pdata.Metric {
metric := pdata.NewMetric()
metric.SetName("system.disk.merged")
metric.SetDescription("The number of disk reads merged into single physical disk access operations.")
metric.SetUnit("1")
metric.SetUnit("{operations}")
metric.SetDataType(pdata.MetricDataTypeIntSum)
sum := metric.IntSum()
sum.SetIsMonotonic(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (s *scraper) scrape(_ context.Context) (pdata.MetricSlice, error) {
if len(ioCounters) > 0 {
metrics.Resize(metricsLen)
initializeDiskIOMetric(metrics.At(0), s.startTime, now, ioCounters)
initializeDiskOpsMetric(metrics.At(1), s.startTime, now, ioCounters)
initializeDiskOperationsMetric(metrics.At(1), s.startTime, now, ioCounters)
initializeDiskIOTimeMetric(metrics.At(2), s.startTime, now, ioCounters)
initializeDiskOperationTimeMetric(metrics.At(3), s.startTime, now, ioCounters)
initializeDiskPendingOperationsMetric(metrics.At(4), now, ioCounters)
Expand All @@ -120,8 +120,8 @@ func initializeDiskIOMetric(metric pdata.Metric, startTime, now pdata.TimestampU
}
}

func initializeDiskOpsMetric(metric pdata.Metric, startTime, now pdata.TimestampUnixNano, ioCounters map[string]disk.IOCountersStat) {
diskOpsDescriptor.CopyTo(metric)
func initializeDiskOperationsMetric(metric pdata.Metric, startTime, now pdata.TimestampUnixNano, ioCounters map[string]disk.IOCountersStat) {
diskOperationsDescriptor.CopyTo(metric)

idps := metric.IntSum().DataPoints()
idps.Resize(2 * len(ioCounters))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestScrape(t *testing.T) {
assert.GreaterOrEqual(t, metrics.Len(), 4)

assertInt64DiskMetricValid(t, metrics.At(0), diskIODescriptor, true, test.expectedStartTime)
assertInt64DiskMetricValid(t, metrics.At(1), diskOpsDescriptor, true, test.expectedStartTime)
assertInt64DiskMetricValid(t, metrics.At(1), diskOperationsDescriptor, true, test.expectedStartTime)
assertDoubleDiskMetricValid(t, metrics.At(2), diskIOTimeDescriptor, false, test.expectedStartTime)
assertDoubleDiskMetricValid(t, metrics.At(3), diskOperationTimeDescriptor, true, test.expectedStartTime)
assertDiskPendingOperationsMetricValid(t, metrics.At(4))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (s *scraper) scrape(ctx context.Context) (pdata.MetricSlice, error) {
if len(logicalDiskCounterValues) > 0 {
metrics.Resize(metricsLen)
initializeDiskIOMetric(metrics.At(0), s.startTime, now, logicalDiskCounterValues)
initializeDiskOpsMetric(metrics.At(1), s.startTime, now, logicalDiskCounterValues)
initializeDiskOperationsMetric(metrics.At(1), s.startTime, now, logicalDiskCounterValues)
initializeDiskIOTimeMetric(metrics.At(2), s.startTime, now, logicalDiskCounterValues)
initializeDiskOperationTimeMetric(metrics.At(3), s.startTime, now, logicalDiskCounterValues)
initializeDiskPendingOperationsMetric(metrics.At(4), now, logicalDiskCounterValues)
Expand All @@ -141,8 +141,8 @@ func initializeDiskIOMetric(metric pdata.Metric, startTime, now pdata.TimestampU
}
}

func initializeDiskOpsMetric(metric pdata.Metric, startTime, now pdata.TimestampUnixNano, logicalDiskCounterValues []*perfcounters.CounterValues) {
diskOpsDescriptor.CopyTo(metric)
func initializeDiskOperationsMetric(metric pdata.Metric, startTime, now pdata.TimestampUnixNano, logicalDiskCounterValues []*perfcounters.CounterValues) {
diskOperationsDescriptor.CopyTo(metric)

idps := metric.IntSum().DataPoints()
idps.Resize(2 * len(logicalDiskCounterValues))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var fileSystemUsageDescriptor = func() pdata.Metric {
metric := pdata.NewMetric()
metric.SetName("system.filesystem.usage")
metric.SetDescription("Filesystem bytes used.")
metric.SetUnit("bytes")
metric.SetUnit("By")
metric.SetDataType(pdata.MetricDataTypeIntSum)
sum := metric.IntSum()
sum.SetIsMonotonic(false)
Expand All @@ -54,7 +54,7 @@ var fileSystemINodesUsageDescriptor = func() pdata.Metric {
metric := pdata.NewMetric()
metric.SetName("system.filesystem.inodes.usage")
metric.SetDescription("FileSystem iNodes used.")
metric.SetUnit("1")
metric.SetUnit("{inodes}")
metric.SetDataType(pdata.MetricDataTypeIntSum)
sum := metric.IntSum()
sum.SetIsMonotonic(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build windows
Copy link
Member Author

Choose a reason for hiding this comment

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

Make Linux the special case instead of Windows, as other systems including Darwin seem to use the same standard names as Windows.

// +build linux

package networkscraper

var allTCPStates = []string{
"CLOSE_WAIT",
"CLOSED",
"CLOSE",
"CLOSING",
"DELETE",
"ESTABLISHED",
Expand All @@ -27,6 +27,6 @@ var allTCPStates = []string{
"LAST_ACK",
"LISTEN",
"SYN_SENT",
"SYN_RECEIVED",
"SYN_RECV",
"TIME_WAIT",
}
Loading