Skip to content

mdatagen cannot generate histogram correctly #14326

@coderdjw

Description

@coderdjw

Component(s)

cmd/mdatagen

What happened?

Describe the bug
I am using mdatagen v0.142.x. I am trying to modify https://github.com/open-telemetry/opentelemetry-collector/blob/main/cmd/mdatagen/internal/samplescraper/metadata.yaml and add a metric using histogram.

mdatagen --version
mdatagen version v0.142.1-0.20251224170331-6282405c5fee+dirty
  system.cpu.utilization:
    enabled: true
    stability:
      level: beta
    description: Gauge double metric enabled by default.
    extended_documentation: The metric will be become optional soon.
    unit: "1"
    histogram:
      value_type: double
      bucket_boundaries: [0.0, 0.25, 0.5, 0.75, 1.0]

But I found the generated_metrics.go has syntax issue and seems histogram report function is not correctly generated.

Image

Steps to reproduce
Change https://github.com/open-telemetry/opentelemetry-collector/blob/main/cmd/mdatagen/internal/samplescraper/metadata.yaml and add above section, then run go generate

$ [open-telemetry/opentelemetry-collector/cmd/mdatagen/internal/samplescraper]: go generate ./...

Then check opentelemetry-collector/cmd/mdatagen/internal/samplescraper/internal/metadata/generated_metrics.go.

What did you expect to see?

What did you see instead?

Collector version

b579eb1

Environment information

Environment

go version go1.25.5 linux/amd64

OpenTelemetry Collector configuration

Log output

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions