Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hostmetricsreceiver] add system uptime metric (open-telemetry#35954)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Add new uptime scraper to emit the `system.uptime` metric <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#31627 <!--Describe what testing was performed and which tests were added.--> #### Testing Unit test added. Also tested locally (Linux VM) with following config: ```yaml receivers: hostmetrics: scrapers: uptime: exporters: debug: verbosity: detailed service: pipelines: metrics: receivers: - hostmetrics exporters: - debug ``` <details><summary>Details</summary> <p> ```console $ make genotelcontribcol [...] $ make RUN_CONFIG=config-uptime.yaml run 2024-10-23T13:24:48.195+0200 info [email protected]/service.go:135 Setting up own telemetry... 2024-10-23T13:24:48.195+0200 info telemetry/metrics.go:70 Serving metrics {"address": "localhost:8888", "metrics level": "Normal"} 2024-10-23T13:24:48.195+0200 info builders/builders.go:26 Development component. May change in the future. {"kind": "exporter", "data_type": "metrics", "name": "debug"} 2024-10-23T13:24:48.199+0200 info [email protected]/service.go:207 Starting otelcontribcol... {"Version": "0.112.0-dev", "NumCPU": 7} 2024-10-23T13:24:48.199+0200 info extensions/extensions.go:39 Starting extensions... 2024-10-23T13:24:48.199+0200 info [email protected]/service.go:230 Everything is ready. Begin running and processing data. 2024-10-23T13:24:49.202+0200 info Metrics {"kind": "exporter", "data_type": "metrics", "name": "debug", "resource metrics": 1, "metrics": 1, "data points": 1} 2024-10-23T13:24:49.202+0200 info ResourceMetrics #0 Resource SchemaURL: https://opentelemetry.io/schemas/1.9.0 ScopeMetrics #0 ScopeMetrics SchemaURL: InstrumentationScope github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/uptimescraper 0.112.0-dev Metric #0 Descriptor: -> Name: system.uptime -> Description: The time the system has been running -> Unit: s -> DataType: Sum -> IsMonotonic: false -> AggregationTemporality: Cumulative NumberDataPoints #0 StartTimestamp: 2024-10-22 18:23:22 +0000 UTC Timestamp: 2024-10-23 11:24:49.202512199 +0000 UTC Value: 61287.000000 {"kind": "exporter", "data_type": "metrics", "name": "debug"} 2024-10-23T13:25:49.206+0200 info Metrics {"kind": "exporter", "data_type": "metrics", "name": "debug", "resource metrics": 1, "metrics": 1, "data points": 1} 2024-10-23T13:25:49.206+0200 info ResourceMetrics #0 Resource SchemaURL: https://opentelemetry.io/schemas/1.9.0 ScopeMetrics #0 ScopeMetrics SchemaURL: InstrumentationScope github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/uptimescraper 0.112.0-dev Metric #0 Descriptor: -> Name: system.uptime -> Description: The time the system has been running -> Unit: s -> DataType: Sum -> IsMonotonic: false -> AggregationTemporality: Cumulative NumberDataPoints #0 StartTimestamp: 2024-10-22 18:23:22 +0000 UTC Timestamp: 2024-10-23 11:25:49.206657828 +0000 UTC Value: 61347.000000 {"kind": "exporter", "data_type": "metrics", "name": "debug"} 2024-10-23T13:26:49.205+0200 info Metrics {"kind": "exporter", "data_type": "metrics", "name": "debug", "resource metrics": 1, "metrics": 1, "data points": 1} 2024-10-23T13:26:49.205+0200 info ResourceMetrics #0 Resource SchemaURL: https://opentelemetry.io/schemas/1.9.0 ScopeMetrics #0 ScopeMetrics SchemaURL: InstrumentationScope github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/uptimescraper 0.112.0-dev Metric #0 Descriptor: -> Name: system.uptime -> Description: The time the system has been running -> Unit: s -> DataType: Sum -> IsMonotonic: false -> AggregationTemporality: Cumulative NumberDataPoints #0 StartTimestamp: 2024-10-22 18:23:22 +0000 UTC Timestamp: 2024-10-23 11:26:49.2051249 +0000 UTC Value: 61407.000000 {"kind": "exporter", "data_type": "metrics", "name": "debug"} 2024-10-23T13:27:49.210+0200 info Metrics {"kind": "exporter", "data_type": "metrics", "name": "debug", "resource metrics": 1, "metrics": 1, "data points": 1} 2024-10-23T13:27:49.210+0200 info ResourceMetrics #0 Resource SchemaURL: https://opentelemetry.io/schemas/1.9.0 ScopeMetrics #0 ScopeMetrics SchemaURL: InstrumentationScope github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/uptimescraper 0.112.0-dev Metric #0 Descriptor: -> Name: system.uptime -> Description: The time the system has been running -> Unit: s -> DataType: Sum -> IsMonotonic: false -> AggregationTemporality: Cumulative NumberDataPoints #0 StartTimestamp: 2024-10-22 18:23:22 +0000 UTC Timestamp: 2024-10-23 11:27:49.21007371 +0000 UTC Value: 61467.000000 {"kind": "exporter", "data_type": "metrics", "name": "debug"} ^C 2024-10-23T13:27:54.204+0200 info [email protected]/collector.go:328 Received signal from OS {"signal": "interrupt"} 2024-10-23T13:27:54.204+0200 info [email protected]/service.go:266 Starting shutdown... 2024-10-23T13:27:54.204+0200 info extensions/extensions.go:66 Stopping extensions... 2024-10-23T13:27:54.204+0200 info [email protected]/service.go:280 Shutdown complete. ``` </p> </details> <!--Describe the documentation added.--> #### Documentation Updated readme & generated scraper docs <!--Please delete paragraphs that you did not use before submitting.-->
- Loading branch information