Repository navigation
[EXPORTER] Prometheus exporter: export instrumentation scope schema URL and attributes as labels - #4735
Open
dashpole wants to merge 1 commit into
Open
[EXPORTER] Prometheus exporter: export instrumentation scope schema URL and attributes as labels#4735dashpole wants to merge 1 commit into
dashpole wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved label collisions can produce invalid Prometheus samples, and array-valued scope attributes lose their values.
2 open issues
What changed in this PR
This PR extends Prometheus instrumentation-scope labels with schema URLs and scope attributes, advancing the exporter compatibility work in #1841.
Changes:
- Adds schema URL and prefixed scope-attribute labels, with reserved-name filtering and scope-attribute collision handling.
- Preserves scope labels when point attributes and the resource are absent.
- Adds regression tests and updates API documentation and the changelog.
| File | Description |
|---|---|
| exporters/prometheus/test/exporter_utils_test.cc | Tests scope labels, opt-out behavior, and scope-attribute collisions. |
| exporters/prometheus/src/exporter_utils.cc | Implements expanded scope labels and adjusts the early return. |
| exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h | Documents the expanded scope-label option. |
| CHANGELOG.md | Records the exporter enhancement. |
Review effort: Balanced
dashpole
force-pushed
the
prom-scope-labels-1841
branch
from
October 25, 2026 15:31
789024b to
a27834e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4735 +/- ##
==========================================
+ Coverage 86.69% 86.73% +0.05%
==========================================
Files 527 527
Lines 20902 20932 +30
==========================================
+ Hits 18119 18154 +35
+ Misses 2783 2778 -5
🚀 New features to boost your workflow:
|
dashpole
force-pushed
the
prom-scope-labels-1841
branch
from
October 25, 2026 16:12
a27834e to
86ab04f
Compare
…RL and attributes as labels Update PrometheusExporterUtils::SetMetricBasic to conform to the OpenTelemetry Prometheus and OpenMetrics compatibility specification: - Export otel_scope_schema_url when InstrumentationScope::GetSchemaURL() is non-empty and without_otel_scope is false. - Export InstrumentationScope attributes as labels with the otel_scope_ prefix, dropping scope attributes that conflict with otel_scope_name, otel_scope_version, or otel_scope_schema_url after sanitization, and concatenating values with ';' in lexicographical order of original keys when sanitized keys collide. Part of open-telemetry#1841
dashpole
force-pushed
the
prom-scope-labels-1841
branch
from
October 26, 2026 18:17
f597923 to
98be712
Compare
2 tasks done
dashpole
marked this pull request as ready for review
October 26, 2026 18:37
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.


Part of #1841
Changes
Update
PrometheusExporterUtils::SetMetricBasicto conform to the Instrumentation Scope section of the OpenTelemetry Prometheus and OpenMetrics Compatibility Specification:otel_scope_schema_urlwhenInstrumentationScope::GetSchemaURL()is non-empty andwithout_otel_scopeisfalse.InstrumentationScopeattributes as labels with theotel_scope_prefix, dropping scope attributes that conflict withotel_scope_name,otel_scope_version, orotel_scope_schema_urlafter sanitization, and concatenating values with;in lexicographical order of original keys when sanitized keys collide.(Pre-existing bug fixes for array attribute serialization, cross-source
otel_scope_*point attribute collisions, and empty point attribute guards have been split into #4738.)For full trivial changes below, please confirm you have:
clang-formatCHANGELOG.mdif applicable