Skip to content

add scope schema URL and attributes to prom attributes #7356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

zeitlinger
Copy link
Member

@zeitlinger zeitlinger commented May 19, 2025

@zeitlinger zeitlinger requested a review from a team as a code owner May 19, 2025 17:01
Copy link

codecov bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.82%. Comparing base (f2f29f5) to head (8cb8418).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7356      +/-   ##
============================================
+ Coverage     89.77%   89.82%   +0.05%     
- Complexity     6982     6988       +6     
============================================
  Files           797      797              
  Lines         21160    21167       +7     
  Branches       2056     2057       +1     
============================================
+ Hits          18996    19014      +18     
+ Misses         1503     1494       -9     
+ Partials        661      659       -2     

☔ View full report in Codecov by Sentry.
📢 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.

@pellared
Copy link
Member

pellared commented May 23, 2025

@zeitlinger, FYI. From open-telemetry/opentelemetry-go#5947 (comment):

SIG meeting:
We agreed that this can be merged before updating the spec given we have a preliminary consent with OTel-Prometheus SIG and both exporter and spec are "development".

@zeitlinger
Copy link
Member Author

@zeitlinger, FYI: open-telemetry/opentelemetry-go#5947 (comment)

from that comment

SIG meeting:
We agreed that this can be merged before updating the spec given we have a preliminary consent with OTel-Prometheus SIG and both exporter and spec are "development".

@ArthurSens
Copy link
Member

This is just a heads-up that the spec change this PR addresses has already been approved and is about to be merged! So you're good to proceed.

If removing the otel_scope_info metric is a breaking change for your SDK, you're empowered to decide how to roll this out!

@zeitlinger zeitlinger changed the title [DO NOT MERGE] add scope schema URL and attributes to prom attributes add scope schema URL and attributes to prom attributes Jun 5, 2025
@zeitlinger zeitlinger force-pushed the otel-scope-attributes branch from 23d8e5b to a1328aa Compare June 5, 2025 13:48
@zeitlinger
Copy link
Member Author

If removing the otel_scope_info metric is a breaking change for your SDK, you're empowered to decide how to roll this out!

This is not part of this PR - will discuss first how to address this

github-merge-queue bot pushed a commit to open-telemetry/opentelemetry-specification that referenced this pull request Jun 5, 2025
Fixes
#4223

Prototypes:
- open-telemetry/opentelemetry-go#5947
- open-telemetry/opentelemetry-go#6770
- open-telemetry/opentelemetry-java#7356
-
open-telemetry/opentelemetry-collector-contrib#40060
-
open-telemetry/opentelemetry-collector-contrib#40004



## Changes

Currently (before this PR) [Prometheus and OpenMetrics
Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/prometheus_and_openmetrics.md)
assumes that only scope name and scope version are identifying.

However, with
#4161
this is no longer true.

Therefore, this PR updates the Prometheus and OpenMetrics Compatibility
specification to add the scope name, version, schema URL, scope
attributes to all metrics.

This also removes the `otel_scope_info` as it looks that it won't be
useful. See:
#4223 (comment).

This change important for Collector
open-telemetry/opentelemetry-go#5846 (comment).
It is also is necessary towards stabilization of OTel-Prom/OpenMetrics
compatibility) and the Prometheus exporter.

_Initially, I thought about [splitting it into a few
PRs](#4223 (comment)).
However, it looks like doing it in one PR would be a more complete
approach (also there are not that many changes)._

---------

Co-authored-by: Jade Guiton <jade.guiton@datadoghq.com>
Co-authored-by: Carlos Alberto Cortez <calberto.cortez@gmail.com>
github-merge-queue bot pushed a commit to open-telemetry/opentelemetry-specification that referenced this pull request Jun 5, 2025
Fixes
#4223

Prototypes:
- open-telemetry/opentelemetry-go#5947
- open-telemetry/opentelemetry-go#6770
- open-telemetry/opentelemetry-java#7356
-
open-telemetry/opentelemetry-collector-contrib#40060
-
open-telemetry/opentelemetry-collector-contrib#40004



## Changes

Currently (before this PR) [Prometheus and OpenMetrics
Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/prometheus_and_openmetrics.md)
assumes that only scope name and scope version are identifying.

However, with
#4161
this is no longer true.

Therefore, this PR updates the Prometheus and OpenMetrics Compatibility
specification to add the scope name, version, schema URL, scope
attributes to all metrics.

This also removes the `otel_scope_info` as it looks that it won't be
useful. See:
#4223 (comment).

This change important for Collector
open-telemetry/opentelemetry-go#5846 (comment).
It is also is necessary towards stabilization of OTel-Prom/OpenMetrics
compatibility) and the Prometheus exporter.

_Initially, I thought about [splitting it into a few
PRs](#4223 (comment)).
However, it looks like doing it in one PR would be a more complete
approach (also there are not that many changes)._

---------

Co-authored-by: Jade Guiton <jade.guiton@datadoghq.com>
Co-authored-by: Carlos Alberto Cortez <calberto.cortez@gmail.com>
@zeitlinger zeitlinger force-pushed the otel-scope-attributes branch from a1328aa to 8cb8418 Compare June 6, 2025 15:01
@zeitlinger
Copy link
Member Author

@jack-berg can you take a look?

Copy link
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestion, but this looks good. In practice, the scope attributes bit of this won't impact any users right now because we never landed the APIs to be able to associate attributes with meter, tracer, logger.

@@ -488,6 +490,14 @@ private Labels convertAttributes(
if (scope.getVersion() != null) {
labelNameToValue.putIfAbsent(OTEL_SCOPE_VERSION, scope.getVersion());
}
String schemaUrl = scope.getSchemaUrl();
labelNameToValue.putIfAbsent(OTEL_SCOPE_SCHEMA_URL, schemaUrl == null ? "" : schemaUrl);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not:

Suggested change
labelNameToValue.putIfAbsent(OTEL_SCOPE_SCHEMA_URL, schemaUrl == null ? "" : schemaUrl);
if (schemaUrl != null) {
labelNameToValue.putIfAbsent(OTEL_SCOPE_SCHEMA_URL, schemaUrl);
}

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.

4 participants