Skip to content

Prometheus exporter incorrectly adding units to metric name #7039

@TylerHelmuth

Description

@TylerHelmuth

Description

I ran into an issue today bumping the operator to the latest collector version (v0.130.0) where the collector's metrics included the unit in the metric name unexpectedly. I expected the collector's emitted metric to be otelcol_exporter_sent_spans_total but saw otelcol_exporter_sent_spans__spans__total.

After investigating, I believe this is a result of #6839. For metrics the use the {} syntax, such as exporter_sent_spans the prometheus exporter is passing the suffix != "" check and proceeding to append the unit. The previous default behavior for a metric like {spans} was to not append the unit.

While I found this via the collector, I expect this issue would occur wherever the prometheus exporter is used.

Environment

  • opentelemetry-go version: v1.37.0

Steps To Reproduce

Run a v0.130.0 collector with the following config:

receivers:
  otlp:
    protocols:
      http:
        endpoint: 0.0.0.0:4318
exporters:
  debug:
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: []
      exporters: [debug]
  telemetry:
    metrics:
      readers:
        - pull:
            exporter:
              prometheus:
                host: 0.0.0.0
                port: 8888

Sent a trace to http://localhost:4318.

Go to http://localhost:8888/metrics and see a metric named otelcol_exporter_sent_spans__spans__total

Expected behavior

A metric named otelcol_exporter_sent_spans_total

Work Around

If you manually set without_units: true the expected behavior occurs.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Closed

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions