mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-10-28 10:45:18 +08:00
## 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 - [x] Added `TestExemplarsExceedingLabelLimit`, verified it fails without the fix (exemplar dropped entirely) and passes with it (trace/span IDs preserved, filtered attributes dropped). - [x] `go test ./... -race` - [x] `make precommit`