open-telemetry / opentelemetry-collector

OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
4.27k stars 1.41k forks source link

mdatagen: telemetry attributes #10926

Open sh0rez opened 3 weeks ago

sh0rez commented 3 weeks ago

In the config spec, mdatagen lists an attributes key for telemetry metrics:

https://github.com/open-telemetry/opentelemetry-collector/blob/fce1d4619dd65e1c53c0b83ccc154f5063ac8612/cmd/mdatagen/metadata-schema.yaml#L167-L168

however, when trying to use it:

attributes:
  test:
    type: string
    description: test

telemetry:
  metrics:
    test:
      description: test
      unit: "1"
      enabled: true
      gauge:
        value_type: int
      attributes: [test]

mdatagen fails:

$ go generate .
2024/08/20 16:49:09 failed loading /home/tbraack/work/otelcol-contrib/processor/deltatocumulativeprocessor/metadata.yaml: unused attributes: [test]
doc.go:4: running "mdatagen": exit status 1

looking at the code, it appears to only check metrics, not telemetry.metrics for attribute usage.

Adding a fake metric to silence the check succeeds, but also does not generate anything.

codeboten commented 3 weeks ago

I think the same fix that will address https://github.com/open-telemetry/opentelemetry-collector/issues/10925 will address this issue as well, can you confirm @sh0rez