exporter/prometheus: Add config option 'resource_constant_labels'#48922
exporter/prometheus: Add config option 'resource_constant_labels'#48922ArthurSens wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Prometheus exporter configuration option to selectively copy resource attributes into metric labels, aligning better with Prometheus/Otel recommendations while keeping backward compatibility via a feature gate.
Changes:
- Introduces
resource_constant_labels(withincluded/excluded) behind theexporter.prometheusexporter.ResourceConstantLabelsfeature gate and disables the legacyresource_to_telemetry_conversionwhen the gate is enabled. - Adds config unmarshalling + validation to enforce mutual exclusivity and feature-gate requirements.
- Updates metric label construction to optionally upsert selected resource attributes into metric labelsets; adds tests and documentation updates.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| exporter/prometheusexporter/testdata/config.yaml | Adds test config coverage for the new and legacy configuration blocks. |
| exporter/prometheusexporter/README.md | Documents resource_constant_labels, deprecates resource_to_telemetry_conversion, and updates usage guidance/examples. |
| exporter/prometheusexporter/prometheus_test.go | Adds an end-to-end scrape test validating resource attribute copying behavior under the feature gate. |
| exporter/prometheusexporter/metadata.yaml | Registers the new feature gate metadata for mdatagen/docs. |
| exporter/prometheusexporter/internal/metadata/generated_feature_gates.go | Adds generated Go registration for the new feature gate. |
| exporter/prometheusexporter/factory.go | Validates config early and conditionally applies the legacy resource-to-telemetry wrapper based on the feature gate. |
| exporter/prometheusexporter/documentation.md | Lists the new feature gate in the autogenerated docs table. |
| exporter/prometheusexporter/config.schema.yaml | Extends the config schema with the optional resource_constant_labels object and deprecation note. |
| exporter/prometheusexporter/config.go | Adds ResourceConstantLabels, custom Unmarshal tracking for legacy presence, and feature-gate/mutual-exclusion validation. |
| exporter/prometheusexporter/config_test.go | Extends config loading tests and adds validation tests around the feature gate behavior. |
| exporter/prometheusexporter/collector.go | Adds optional copying of selected resource attributes into metric labels (with collision-safe upsert behavior). |
| exporter/prometheusexporter/collector_test.go | Adds a focused unit test asserting include/exclude behavior and precedence when keys overlap. |
Files not reviewed (1)
- exporter/prometheusexporter/internal/metadata/generated_feature_gates.go: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description While working on #48922, CI complained about broken links. Looks like the old page got moved by prometheus/docs#2656 Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
89cac4d to
c813473
Compare
| from_version: "v0.132.0" | ||
| reference_url: https://github.com/open-telemetry/opentelemetry-specification/pull/4533 | ||
| skip_strict_validation: true | ||
| - id: exporter.prometheusexporter.ResourceConstantLabels |
There was a problem hiding this comment.
I usually prefer just having the feature gate guard the deprecation of the old thing, and not prevent people from using the new thing. I.e. just make this exporter.prometheusexporter.RemoveResourceToTelemetry
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
|
Let's put this PR on hold until open-telemetry/opentelemetry-specification#5130 is sorted out |
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Pull request dashboard statusStatus last refreshed: 2026-07-24 15:35:18 UTC.
This automated status or its linked feedback items may be incorrect. If something looks wrong, please report it with the result you expected. |
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description While working on open-telemetry#48922, CI complained about broken links. Looks like the old page got moved by prometheus/docs#2656 Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Description
Adds the config option
resource_constant_labelswith two arraysincludeandexclude, to select which resource attributes are translated to labels during exposition.The new config is hidden behind a feature gate that, once enabled, will also disable the deprecated config option
resource_to_telemetry_conversion, which uses an "all or nothing" approach.Link to tracking issue
Fixes #48861
Authorship