Repository navigation
Do not promote resource attributes for empty resource_constant_labels - #9048
Open
samirsahoo wants to merge 1 commit into
Open
samirsahoo wants to merge 1 commit into
samirsahoo wants to merge 1 commit into
Conversation
An empty `resource_constant_labels: {}` mapping in declarative configuration
leaves both `included` and `excluded` null. `PrometheusComponentProvider`
passed both to `IncludeExcludePredicate.createPatternMatching`, which returns
an include-all predicate, so every resource attribute was added as a label on
every exported metric series.
The prometheus exporter specification requires that no resource attributes are
added as metric labels by default, so leave the filter unset when neither
`included` nor `excluded` is configured.
Fixes open-telemetry#9014
|
|
Pull request dashboard statusWaiting on reviewers · refreshed 2026-11-23 02:27 UTC Review the latest changes. Status above doesn't look right?
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9048 +/- ##
=========================================
Coverage 90.45% 90.46%
- Complexity 11182 11188 +6
=========================================
Files 1032 1032
Lines 30508 30509 +1
Branches 3992 3993 +1
=========================================
+ Hits 27596 27599 +3
+ Misses 1935 1934 -1
+ Partials 977 976 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Author
|
Signed the EasyCLA |
This branch has not been deployed
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.
Fixes #9014
Problem
An empty
resource_constant_labels: {}mapping is valid against theopentelemetry-configurationJSON Schema, and parses into a non-nullDeclarativeConfigPropertieswhoseincludedandexcludedare bothnull.PrometheusComponentProviderpassed both toIncludeExcludePredicate.createPatternMatching(null, null), which returns an include-all predicate (attributeKey -> true). The result is that every resource attribute was added as a label on every exported metric series:Fix
Only set the filter when at least one of
included/excludedis configured. When neither is, the filter stays unset, which is the default of no resource attributes as metric labels.This matches the prometheus exporter specification ("By default, it MUST NOT add any resource attributes as metric labels"), the documented
defaultBehaviorofExperimentalPrometheusMetricExporter.resource_constant_labels, and the Collector'spkg/resourcetotelemetryIsEmpty()check.The existing validation that rejects an explicitly empty
included: []orexcluded: []list is unchanged.Tests
Adds
PrometheusComponentProviderTestcoveringresource_constant_labelsabsent, empty ({}),included,excluded, and the two empty-list rejections. Reverting the one-line guard fails exactly the empty-mapping case.