Skip to content

Do not promote resource attributes when Prometheus resource_constant_labels is empty (#9014) - #9015

Open
rooks-ns wants to merge 1 commit into
open-telemetry:mainfrom
rooks-ns:fix/prometheus-empty-resource-constant-labels
Open

rooks-ns wants to merge 1 commit into
open-telemetry:mainfrom
rooks-ns:fix/prometheus-empty-resource-constant-labels

Conversation

@rooks-ns

@rooks-ns rooks-ns commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #9014

Problem

In declarative configuration, $defs.IncludeExclude allows an empty object (resource_constant_labels: {}). When parsed, PrometheusComponentProvider unconditionally forwarded (null, null) to IncludeExcludePredicate.createPatternMatching(null, null). Because IncludeExcludePredicate defaults (null, null) to s -> true (match all), this erroneously promoted every resource attribute onto all Prometheus metric time-series instead of none.

Solution

Only register allowedResourceAttributesFilter on the builder when included != null || excluded != null. If both are absent, the builder retains allowedResourceAttributesFilter = null (no-op), ensuring zero resource attributes are converted to metric labels.

Testing

  • Added PrometheusComponentProviderTest covering default behavior, empty {} config, whitelist, blacklist, and validation errors.
  • Added test case to MetricReaderFactoryTest verifying declarative config model parity with empty IncludeExcludeModel.
  • Verified via ./gradlew :exporters:prometheus:check :sdk-extensions:declarative-config:check.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-11-07 05:29 UTC

Investigate required status check failures.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.37%. Comparing base (d97e4af) to head (245467d).
⚠️ Report is 24 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9015      +/-   ##
============================================
+ Coverage     90.35%   90.37%   +0.01%     
- Complexity    10984    11025      +41     
============================================
  Files          1019     1021       +2     
  Lines         30072    30129      +57     
  Branches       3927     3934       +7     
============================================
+ Hits          27173    27229      +56     
- Misses         1939     1942       +3     
+ Partials        960      958       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rooks-ns
rooks-ns marked this pull request as ready for review November 7, 2026 05:28
@rooks-ns
rooks-ns requested a review from a team as a code owner November 7, 2026 05:28

This branch has not been deployed

No deployments
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.

PrometheusComponentProvider promotes all resource attributes when resource_constant_labels is empty ({})

1 participant