Repository navigation
Do not promote resource attributes when Prometheus resource_constant_labels is empty (#9014) - #9015
Conversation
Pull request dashboard statusMerged · refreshed 2026-12-04 17:15 UTC 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 #9015 +/- ##
=========================================
Coverage 90.50% 90.50%
- Complexity 11260 11265 +5
=========================================
Files 1040 1040
Lines 30737 30738 +1
Branches 4029 4030 +1
=========================================
+ Hits 27817 27819 +2
Misses 1934 1934
+ Partials 986 985 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@dashpole PTAL. |
This comment has been minimized.
This comment has been minimized.
|
Hey I think the linked issue incorrectly reports a bug and the current behavior is correct. See this comment. Let's hold off on this until we resolve whether or not this is indeed a bug in the linked issue. |
|
|
||
| @ExtendWith(MockitoExtension.class) | ||
| @MockitoSettings(strictness = Strictness.LENIENT) | ||
| class PrometheusComponentProviderTest { |
There was a problem hiding this comment.
Could we consolidate this coverage into the existing parameterized MetricReaderFactoryTest? It already covers defaults and combined include/exclude filters, and this PR adds the empty-map regression case there. Adding included-only and excluded-only cases would cover all four combinations for the new || condition without a separate test class, mocked configuration, or another port-allocation helper. The name/type and validation tests exercise unchanged behavior. That would also let us drop the added api:incubator test dependency.
245467d to
e8d6d71
Compare
Fixes #9014
Problem
In declarative configuration,
$defs.IncludeExcludeallows an empty object (resource_constant_labels: {}). When parsed,PrometheusComponentProviderunconditionally forwarded(null, null)toIncludeExcludePredicate.createPatternMatching(null, null). BecauseIncludeExcludePredicatedefaults(null, null)tos -> true(match all), this erroneously promoted every resource attribute onto all Prometheus metric time-series instead of none.Solution
Only register
allowedResourceAttributesFilteron the builder whenincluded != null || excluded != null. If both are absent, the builder retainsallowedResourceAttributesFilter = null(no-op), ensuring zero resource attributes are converted to metric labels.Testing
PrometheusComponentProviderTestcovering default behavior, empty{}config, whitelist, blacklist, and validation errors.MetricReaderFactoryTestverifying declarative config model parity with emptyIncludeExcludeModel../gradlew :exporters:prometheus:check :sdk-extensions:declarative-config:check.