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

Open Beginner friendly
#9,014 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@rooks-ns is already working on this.

Since Nov 7, 2026.

  • #9015 by @rooks-ns — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java, prometheus

Research direction

Start in exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/internal/PrometheusComponentProvider.java, especially the resource_constant_labels parsing around lines 63–76, and trace how an empty configuration reaches IncludeExcludePredicate.createPatternMatching. Check the related predicate tests and Prometheus exporter tests first. Done means an empty map adds no resource attributes as metric labels, with regression coverage for that configuration.

Written by the indexing model from the issue text.

Description

Describe the bug

In PrometheusComponentProvider.java, configuring an empty resource_constant_labels: {} map in declarative configuration promotes all resource attributes onto every Prometheus metric series instead of none.

resource_constant_labels: {} is currently valid against the opentelemetry-configuration JSON Schema ($defs.IncludeExclude sets minItems: 1 on included and excluded, not minProperties: 1 on the object). When parsed:

meter_provider:
  readers:
    - pull:
        exporter:
          prometheus/development:
            resource_constant_labels: {}

config.getStructured("resource_constant_labels") returns a non-null DeclarativeConfigProperties where both included and excluded are null, and passes (null, null) to IncludeExcludePredicate.createPatternMatching(null, null), which returns an include-all predicate (attributeKey -> true).

Expected behavior

Per the Prometheus exporter specification (By default, it MUST NOT add any resource attributes as metric labels) and ExperimentalPrometheusMetricExporter.resource_constant_labels (defaultBehavior: no resource attributes are added), when both included and excluded are null (matching Collector's pkg/resourcetotelemetry IsEmpty() check), no resource attributes should be added as metric labels (or empty {} should be rejected if disallowed by opentelemetry-configuration).

Dominant language
Java
Stars
2.5k
Forks
1k
Avg merge
4d 3h
Merged PRs (30d)
49

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from open-telemetry/opentelemetry-java

All issues in open-telemetry/opentelemetry-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.