otlptranslator: filter __name__ from OTLP attributes to prevent duplicates#17917
Merged
aknuds1 merged 2 commits intoprometheus:mainfrom Jan 24, 2026
Merged
Conversation
ArthurSens
reviewed
Jan 23, 2026
Member
ArthurSens
left a comment
There was a problem hiding this comment.
Oh wow, did you see that actually happening? 😱
Either way, it's a good bugfix. LGTM! Just one small suggestion
Contributor
Author
@ArthurSens No, it's just a defensive fix. Mainly to rule out the OTLP translation as a possible cause of this type of bug. |
…cates
OTLP metrics can have a __name__ attribute which, when combined with the
metric name passed via extras, creates duplicate __name__ labels. This
causes TSDB compaction failures with errors like:
corruption detected when writing postings to index: label "__name__"
has 7479 uses, but maxPostings is 7477
The fix filters reserved label names (currently just __name__) from OTLP
attributes in all data point handlers: gauge, sum, histogram, exponential
histogram, custom buckets histogram, and summary.
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
bbfcbae to
a885ef0
Compare
Add a subtest to TestPrometheusConverter_createAttributes to verify that __type__ and __unit__ attributes in OTLP data are correctly overwritten by auto-generated labels from metadata when EnableTypeAndUnitLabels is enabled. Also rename TestCreateAttributes to TestPrometheusConverter_createAttributes for consistency, and move TestOTLPNameAttributeFiltered into a subtest. Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
a885ef0 to
24ccb57
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue(s) does the PR fix:
OTLP metrics with a
__name__attribute may create duplicate__name__labels.Does this PR introduce a user-facing change?
Description
In data point handlers, all calls to
createAttributespassnilforignoreAttrs, allowing__name__attributes from OTLP data to pass through. Since__name__is also added via theextrasparameter, this creates duplicate labels.This PR adds a
reservedLabelNamesslice and updates all data point handlers to filter these reserved labels:addGaugeNumberDataPointsaddSumNumberDataPointsaddHistogramDataPointsaddSummaryDataPointsaddExponentialHistogramDataPointsaddCustomBucketsHistogramDataPointsIncludes regression tests verifying that only one
__name__label exists and the correct metric name is used.