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

[processor/resourcedetection] Add support for host cpuinfo attributes #26533

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Sep 8, 2023

Description: : Added support for host's cpuinfo attributes
as part of the system resourcedetection. This information
is retrieved from /proc/cpuinfo.

Link to tracking Issue: #26532

Testing:

How to test this manually

  1. Using the following configuration:
receivers:
  hostmetrics:
    collection_interval: 30s
    scrapers:
      cpu:

processors:
  resourcedetection/system:
    detectors: ["system"]
    system:
      hostname_sources: ["lookup", "cname", "dns", "os"]
      resource_attributes:
        host.name:
          enabled: true
        host.id:
          enabled: true
        host.cpu.cache.l2.size:
          enabled: true
        host.cpu.family:
          enabled: true
        host.cpu.model.id:
          enabled: true
        host.cpu.model.name:
          enabled: true
        host.cpu.stepping:
          enabled: true
        host.cpu.vendor.id:
          enabled: true

service:
  pipelines:
    metrics:
      receivers: [hostmetrics]
      exporters: [file]
      processors: [resourcedetection/system]

exporters:
  file:
    path: ./output.json
  1. Start the collector with ./bin/otelcontribcol_linux_amd64 --config examples/host_config.yaml
  2. The output reports the added attributes succesfully:
  {
    "resourceMetrics":[
      {
        "resource":{
          "attributes":[
            {
              "key":"host.name",
              "value":{
                "stringValue":"chrismark-ThinkPad-X1-Carbon-Gen-9"
              }
            },
            {
              "key":"os.type",
              "value":{
                "stringValue":"linux"
              }
            },
            {
              "key":"host.id",
              "value":{
                "stringValue":"d6488716404e4ce4854ff0e230944c6d"
              }
            },
            {
              "key":"host.cpu.vendor.id",
              "value":{
                "stringValue":"GenuineIntel"
              }
            },
            {
              "key":"host.cpu.family",
              "value":{
                "stringValue":"6"
              }
            },
            {
              "key":"host.cpu.model.id",
              "value":{
                "stringValue":"140"
              }
            },
            {
              "key":"host.cpu.model.name",
              "value":{
                "stringValue":"11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz"
              }
            },
            {
              "key":"host.cpu.stepping",
              "value":{
                "intValue":"1"
              }
            },
            {
              "key":"host.cpu.cache.l2.size",
              "value":{
                "intValue":"12288"
              }
            }
          ]
        },
        "scopeMetrics":[...],
        "schemaUrl":"https://opentelemetry.io/schemas/1.9.0"
      }
    ]
  }

Unit tests

Documentation: Updated README.md

@github-actions github-actions bot added the processor/resourcedetection Resource detection processor label Sep 8, 2023
@ChrsMark ChrsMark force-pushed the add_host_cpuinfo branch 3 times, most recently from 4913134 to 0c02a8e Compare September 11, 2023 08:36
@ChrsMark ChrsMark force-pushed the add_host_cpuinfo branch 2 times, most recently from fd3794c to d84f1e2 Compare September 11, 2023 09:04
@ChrsMark ChrsMark marked this pull request as ready for review September 11, 2023 09:41
@ChrsMark ChrsMark requested a review from a team September 11, 2023 09:41
@mx-psi mx-psi requested review from dmitryax and frzifus September 11, 2023 15:12
@ChrsMark ChrsMark force-pushed the add_host_cpuinfo branch 2 times, most recently from ca82c2d to ecdc295 Compare September 12, 2023 08:07
@ChrsMark ChrsMark requested a review from mx-psi September 12, 2023 12:31
Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

# github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/system
Error: internal/system/system.go:152:20: fmt.Errorf call has arguments but no formatting directives
Error: internal/system/system.go:158:20: fmt.Errorf call has arguments but no formatting directives

@ChrsMark ChrsMark force-pushed the add_host_cpuinfo branch 4 times, most recently from d40687c to fa7712f Compare September 12, 2023 14:36
mx-psi
mx-psi previously approved these changes Sep 12, 2023
examples/basico.yaml Outdated Show resolved Hide resolved
output.json Outdated Show resolved Hide resolved
@mx-psi mx-psi dismissed their stale review September 12, 2023 15:01

Some stray files

**Description:** : Added support for host's cpuinfo attributes
                   as part of the system resourcedetection. This information
		   is retrieved from /proc/cpuinfo.

**Link to tracking Issue:** open-telemetry#26532

Signed-off-by: ChrsMark <[email protected]>
@ChrsMark
Copy link
Member Author

Thanks for the reviews @mx-psi ! The leftovers are now addressed and the CI is happy. Feel to free to have another look :).

Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

Will wait a few days before merging to give @dmitryax and @frzifus a chance to have a look

@mx-psi mx-psi merged commit b6f4597 into open-telemetry:main Sep 18, 2023
94 checks passed
@github-actions github-actions bot added this to the next release milestone Sep 18, 2023
mx-psi added a commit that referenced this pull request Nov 13, 2023
…odel to string (#29152)

**Description:** 

Add feature gate to change family and CPU model to string, to adapt to
open-telemetry/semantic-conventions/issues/495.

**Link to tracking Issue:** Fixes #29025

**Testing:** Tested with the sample configuration on #26533.
RoryCrispin pushed a commit to ClickHouse/opentelemetry-collector-contrib that referenced this pull request Nov 24, 2023
…odel to string (open-telemetry#29152)

**Description:** 

Add feature gate to change family and CPU model to string, to adapt to
open-telemetry/semantic-conventions/issues/495.

**Link to tracking Issue:** Fixes open-telemetry#29025

**Testing:** Tested with the sample configuration on open-telemetry#26533.
mx-psi added a commit that referenced this pull request Nov 30, 2023
…ostCPUModelAndFamilyAsString` to beta (#29462)

**Description:** 

Follow up to #29152. The feature gate has been in alpha for two releases
(v0.89.0 and v0.90.0).

**Link to tracking Issue:** Relates to #29025 and to
open-telemetry/semantic-conventions/issues/495.

**Testing:** Tested with the sample configuration on #26533.
mx-psi pushed a commit that referenced this pull request Feb 29, 2024
…string (#31165)

#31136

Description:

Add feature gate to change CPU stepping to string, to adapt to
open-telemetry/semantic-conventions#664.

Link to tracking Issue: Fixes
#31136

Testing: Tested with the sample configuration on
#26533.


### Logs

```console
2024-02-09T15:18:02.014+0200	info	[email protected]/telemetry.go:59	Setting up own telemetry...
2024-02-09T15:18:02.014+0200	info	[email protected]/telemetry.go:104	Serving metrics	{"address": ":8888", "level": "Basic"}
2024-02-09T15:18:02.015+0200	info	[email protected]/service.go:140	Starting otelcontribcol...	{"Version": "0.94.0-dev", "NumCPU": 8}
2024-02-09T15:18:02.015+0200	info	extensions/extensions.go:34	Starting extensions...
2024-02-09T15:18:02.015+0200	info	internal/resourcedetection.go:125	began detecting resource information	{"kind": "processor", "name": "resourcedetection/system", "pipeline": "metrics"}
2024-02-09T15:18:02.015+0200	info	system/system.go:209	This attribute changed from int to string. Temporarily switch back to int using the feature gate.	{"kind": "processor", "name": "resourcedetection/system", "pipeline": "metrics", "attribute": "host.cpu.family", "feature gate": "processor.resourcedetection.hostCPUModelAndFamilyAsString"}
2024-02-09T15:18:02.015+0200	info	system/system.go:228	This attribute changed from int to string. Temporarily switch back to int using the feature gate.	{"kind": "processor", "name": "resourcedetection/system", "pipeline": "metrics", "attribute": "host.cpu.model.id", "feature gate": "processor.resourcedetection.hostCPUModelAndFamilyAsString"}
2024-02-09T15:18:02.015+0200	info	system/system.go:245	This attribute changed from int to string. Temporarily switch back to int using the feature gate.	{"kind": "processor", "name": "resourcedetection/system", "pipeline": "metrics", "attribute": "host.cpu.stepping", "feature gate": "processor.resourcedetection.hostCPUSteppingAsString"}
2024-02-09T15:18:02.015+0200	info	internal/resourcedetection.go:139	detected resource information	{"kind": "processor", "name": "resourcedetection/system", "pipeline": "metrics", "resource": {"host.cpu.cache.l2.size":12288,"host.cpu.family":"6","host.cpu.model.id":"140","host.cpu.model.name":"11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz","host.cpu.stepping":"%!f(int32=1)","host.cpu.vendor.id":"GenuineIntel","host.id":"d6488716404e4ce4854ff0e230944c6d","host.name":"chrismark-ThinkPad-X1-Carbon-Gen-9","os.type":"linux"}}
2024-02-09T15:18:02.016+0200	info	[email protected]/service.go:166	Everything is ready. Begin running and processing data.
2024-02-09T15:18:02.016+0200	warn	localhostgate/featuregate.go:63	The default endpoints for all servers in components will change to use localhost instead of 0.0.0.0 in a future version. Use the feature gate to preview the new default.	{"feature gate ID": "component.UseLocalHostAsDefaultHost"}
```

### Sample output

```json
{"resourceMetrics":[{"resource":{"attributes":[{"key":"host.name","value":{"stringValue":"chrismark-ThinkPad-X1-Carbon-Gen-9"}},{"key":"os.type","value":{"stringValue":"linux"}},{"key":"host.id","value":{"stringValue":"d6488716404e4ce4854ff0e230944c6d"}},{"key":"host.cpu.vendor.id","value":{"stringValue":"GenuineIntel"}},{"key":"host.cpu.family","value":{"stringValue":"6"}},{"key":"host.cpu.model.id","value":{"stringValue":"140"}},{"key":"host.cpu.model.name","value":{"stringValue":"11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz"}},{"key":"host.cpu.stepping","value":{"stringValue":"%!f(int32=1)"}},{"key":"host.cpu.cache.l2.size","value":{"intValue":"12288"}}]},"scopeMetrics":[{"scope":{"name":"otelcol/hostmetricsreceiver/cpu","version":"0.94.0-dev"},"metrics":[{"name":"system.cpu.time","description":"Total seconds each logical CPU spent on each mode.","unit":"s","sum":{"dataPoints":[{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1273.45},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":174.29},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19845.95},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.95},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":18.22},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":29.94},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1327.97},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":175.68},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19804.5},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.06},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":9.11},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":28.7},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1249.04},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":178.22},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19846.01},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":2.48},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":10.42},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":26.88},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1211.17},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":176.69},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19912.68},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.45},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":4.92},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":28.48},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1254.73},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":179.59},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19869.65},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.11},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":2.92},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":25.91},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1272.94},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":176.64},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19825.63},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.01},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":3.33},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":24.5},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1317.85},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":176.44},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19803.92},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.7},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":3.87},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":32.35},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1238.01},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":198.62},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19849},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.84},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":2.49},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":27.29}],"aggregationTemporality":2,"isMonotonic":true}}]}],"schemaUrl":"https://opentelemetry.io/schemas/1.9.0"}]}
```

cc: @mx-psi

Signed-off-by: ChrsMark <[email protected]>
XinRanZhAWS pushed a commit to XinRanZhAWS/opentelemetry-collector-contrib that referenced this pull request Mar 13, 2024
…string (open-telemetry#31165)

open-telemetry#31136

Description:

Add feature gate to change CPU stepping to string, to adapt to
open-telemetry/semantic-conventions#664.

Link to tracking Issue: Fixes
open-telemetry#31136

Testing: Tested with the sample configuration on
open-telemetry#26533.


### Logs

```console
2024-02-09T15:18:02.014+0200	info	[email protected]/telemetry.go:59	Setting up own telemetry...
2024-02-09T15:18:02.014+0200	info	[email protected]/telemetry.go:104	Serving metrics	{"address": ":8888", "level": "Basic"}
2024-02-09T15:18:02.015+0200	info	[email protected]/service.go:140	Starting otelcontribcol...	{"Version": "0.94.0-dev", "NumCPU": 8}
2024-02-09T15:18:02.015+0200	info	extensions/extensions.go:34	Starting extensions...
2024-02-09T15:18:02.015+0200	info	internal/resourcedetection.go:125	began detecting resource information	{"kind": "processor", "name": "resourcedetection/system", "pipeline": "metrics"}
2024-02-09T15:18:02.015+0200	info	system/system.go:209	This attribute changed from int to string. Temporarily switch back to int using the feature gate.	{"kind": "processor", "name": "resourcedetection/system", "pipeline": "metrics", "attribute": "host.cpu.family", "feature gate": "processor.resourcedetection.hostCPUModelAndFamilyAsString"}
2024-02-09T15:18:02.015+0200	info	system/system.go:228	This attribute changed from int to string. Temporarily switch back to int using the feature gate.	{"kind": "processor", "name": "resourcedetection/system", "pipeline": "metrics", "attribute": "host.cpu.model.id", "feature gate": "processor.resourcedetection.hostCPUModelAndFamilyAsString"}
2024-02-09T15:18:02.015+0200	info	system/system.go:245	This attribute changed from int to string. Temporarily switch back to int using the feature gate.	{"kind": "processor", "name": "resourcedetection/system", "pipeline": "metrics", "attribute": "host.cpu.stepping", "feature gate": "processor.resourcedetection.hostCPUSteppingAsString"}
2024-02-09T15:18:02.015+0200	info	internal/resourcedetection.go:139	detected resource information	{"kind": "processor", "name": "resourcedetection/system", "pipeline": "metrics", "resource": {"host.cpu.cache.l2.size":12288,"host.cpu.family":"6","host.cpu.model.id":"140","host.cpu.model.name":"11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz","host.cpu.stepping":"%!f(int32=1)","host.cpu.vendor.id":"GenuineIntel","host.id":"d6488716404e4ce4854ff0e230944c6d","host.name":"chrismark-ThinkPad-X1-Carbon-Gen-9","os.type":"linux"}}
2024-02-09T15:18:02.016+0200	info	[email protected]/service.go:166	Everything is ready. Begin running and processing data.
2024-02-09T15:18:02.016+0200	warn	localhostgate/featuregate.go:63	The default endpoints for all servers in components will change to use localhost instead of 0.0.0.0 in a future version. Use the feature gate to preview the new default.	{"feature gate ID": "component.UseLocalHostAsDefaultHost"}
```

### Sample output

```json
{"resourceMetrics":[{"resource":{"attributes":[{"key":"host.name","value":{"stringValue":"chrismark-ThinkPad-X1-Carbon-Gen-9"}},{"key":"os.type","value":{"stringValue":"linux"}},{"key":"host.id","value":{"stringValue":"d6488716404e4ce4854ff0e230944c6d"}},{"key":"host.cpu.vendor.id","value":{"stringValue":"GenuineIntel"}},{"key":"host.cpu.family","value":{"stringValue":"6"}},{"key":"host.cpu.model.id","value":{"stringValue":"140"}},{"key":"host.cpu.model.name","value":{"stringValue":"11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz"}},{"key":"host.cpu.stepping","value":{"stringValue":"%!f(int32=1)"}},{"key":"host.cpu.cache.l2.size","value":{"intValue":"12288"}}]},"scopeMetrics":[{"scope":{"name":"otelcol/hostmetricsreceiver/cpu","version":"0.94.0-dev"},"metrics":[{"name":"system.cpu.time","description":"Total seconds each logical CPU spent on each mode.","unit":"s","sum":{"dataPoints":[{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1273.45},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":174.29},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19845.95},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.95},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":18.22},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu0"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":29.94},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1327.97},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":175.68},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19804.5},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.06},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":9.11},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu1"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":28.7},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1249.04},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":178.22},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19846.01},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":2.48},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":10.42},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu2"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":26.88},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1211.17},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":176.69},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19912.68},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.45},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":4.92},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu3"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":28.48},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1254.73},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":179.59},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19869.65},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.11},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":2.92},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu4"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":25.91},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1272.94},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":176.64},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19825.63},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.01},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":3.33},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu5"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":24.5},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1317.85},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":176.44},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19803.92},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.7},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":3.87},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu6"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":32.35},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"user"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":1238.01},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"system"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":198.62},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"idle"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":19849},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"interrupt"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"nice"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0.84},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"softirq"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":2.49},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"steal"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":0},{"attributes":[{"key":"cpu","value":{"stringValue":"cpu7"}},{"key":"state","value":{"stringValue":"wait"}}],"startTimeUnixNano":"1707463254000000000","timeUnixNano":"1707484683016351289","asDouble":27.29}],"aggregationTemporality":2,"isMonotonic":true}}]}],"schemaUrl":"https://opentelemetry.io/schemas/1.9.0"}]}
```

cc: @mx-psi

Signed-off-by: ChrsMark <[email protected]>
@ChrsMark ChrsMark deleted the add_host_cpuinfo branch April 11, 2024 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
processor/resourcedetection Resource detection processor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants