Skip to content

exporters/prometheus: preserve exemplar trace/span IDs over filtered attribute labels - #9031

Open
om7057 wants to merge 2 commits into
open-telemetry:mainfrom
om7057:prometheus-exemplar-label-limit
Open

om7057 wants to merge 2 commits into
open-telemetry:mainfrom
om7057:prometheus-exemplar-label-limit

Conversation

@om7057

@om7057 om7057 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #6718.

prometheus client-go rejects exemplars whose combined label runes exceed prometheus.ExemplarMaxRunes (128). addExemplars let that error propagate up from prometheus.NewMetricWithExemplars and dropped every exemplar for the data point when the limit was hit, even though the trace and span ID labels alone are well within the limit and are the most valuable part of an exemplar.

This checks each exemplar's combined label length against the limit before building the exemplar. When it would exceed the limit, the filtered-attribute-derived labels are dropped and only the trace and span IDs are kept, with a warning logged via global.Warn so the truncation is visible instead of silent.

Test plan

  • Added TestExemplarsExceedingLabelLimit, verified it fails without the fix (exemplar dropped entirely) and passes with it (trace/span IDs preserved, filtered attributes dropped).
  • go test ./... -race
  • make precommit

…attribute labels

prometheus client-go rejects exemplars whose combined label runes exceed
ExemplarMaxRunes (128). addExemplars previously let that error propagate
and dropped every exemplar for the data point when the limit was hit,
even though the trace and span ID labels alone are well within the
limit.

Instead, drop the filtered-attribute-derived labels and keep the trace
and span IDs when the combined labels would exceed the limit, logging
a warning so the truncation is visible.

Fixes open-telemetry#6718
@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.1%. Comparing base (40679e6) to head (ceeae93).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #9031   +/-   ##
=====================================
  Coverage   89.1%   89.1%           
=====================================
  Files        338     338           
  Lines      22274   22287   +13     
=====================================
+ Hits       19854   19867   +13     
  Misses      2420    2420           
Files with missing lines Coverage Δ
exporters/prometheus/exporter.go 93.2% <100.0%> (+0.1%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread CHANGELOG.md Outdated
- Retain instrument advisory attributes (`metric/x.WithDefaultAttributes`) when a matching View does not specify an attribute filter in `go.opentelemetry.io/otel/sdk/metric`. (#8859)
- Ignore HTTP URL paths when building OTLP/gRPC metric exporter targets from `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`, while preserving `unix://` and `unix-abstract://` targets; treat `unix-abstract://` endpoints as insecure in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` and `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`. (#8862)
- Ignore HTTP(S) paths when deriving gRPC trace exporter endpoints from `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`. (#8852)
- Preserve exemplar trace and span IDs in `go.opentelemetry.io/otel/exporters/prometheus` by dropping filtered attribute labels instead of the whole exemplar when the combined exemplar labels would exceed the prometheus client-go limit.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing PR number?

@om7057

om7057 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Good catch, added the PR number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prometheus Exporter adds filtered labels to exemplars, causing them to exceed exemplar size limit

2 participants