Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

pellared
Copy link
Member

@pellared pellared commented Nov 7, 2024

Fixes #5846

Towards open-telemetry/opentelemetry-specification#4223 (first two points from open-telemetry/opentelemetry-specification#4223 (comment))

  • Add instrumentation scope schema URL as otel_scope_schema_url label to exported metrics
  • Add instrumentation scope attributes as otel_scope_[attribute] labels to exported metrics

Side notes:

  • The exporter does not seem to work correctly if the end user adds e.g. an otel_scope_name attribute. I think the exporter should ignore all attributes with names that have prefix otel_scope_. This scenario is also not covered by the spec. I think it may be covered by a separate PR and issue.
  • Removal of otel_scope_info metric would be handled as a separate PR. prometheus: remove otel_scope_info #6770

@pellared
Copy link
Member Author

pellared commented Nov 7, 2024

@dashpole PTAL

@codecov
Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.0%. Comparing base (1dca080) to head (64fdbd9).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@     Coverage Diff      @@
##   main   #5947   +/-   ##
============================
============================
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pellared pellared changed the title [POC] prometheus: Add otel_scope_schema_url and otel_scope_[attribute] labels prometheus: Add otel_scope_schema_url and otel_scope_[attribute] labels Nov 7, 2024
Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

Is this blocked by spec work? How can I help move this forward?

@pellared
Copy link
Member Author

Is this blocked by spec work? How can I help move this forward?

Yes. See #5846 (comment)

@pellared
Copy link
Member Author

Adding otel_scope_schema_url could be extracted to a seperate PR (and issue).

@pellared

This comment was marked as resolved.

@pellared
Copy link
Member Author

pellared commented May 9, 2025

Question: Should we set the otel_scope_schema_url and otel_scope_version (legacy) labels if the values are empty?

Guessing that yes so that we can easily distinguish e.g. from metrics which have a otel_scope_version set.

@pellared pellared changed the title prometheus: Add otel_scope_schema_url and otel_scope_[attribute] labels [Prototype] prometheus: Add otel_scope_schema_url and otel_scope_[attribute] labels May 9, 2025
@pellared pellared added blocked:specification Waiting on clarification of the OpenTelemetry specification before progress can be made pkg:exporter:prometheus Related to the Prometheus exporter package labels May 9, 2025
@pellared pellared marked this pull request as ready for review May 9, 2025 08:32
@pellared pellared requested review from MrAlias, XSAM and dmathieu as code owners May 9, 2025 08:32
@pellared pellared requested a review from mx-psi May 9, 2025 08:32
@pellared pellared requested a review from dashpole May 9, 2025 08:46
@ArthurSens
Copy link
Member

Question: Should we set the otel_scope_schema_url and otel_scope_version (legacy) labels if the values are empty?

Guessing that yes so that we can easily distinguish e.g. from metrics which have a otel_scope_version set.

Taking Prometheus (the server) out of the scope, I guess it makes sense. Someone looking at a /metrics endpoint will quickly understand if they are empty or unset.

Prometheus won't store anything for them, though, and the filter on the query my_metric{non_existing_label=""} is a no-op.

image

@pellared
Copy link
Member Author

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".

@pellared pellared changed the title [DO NOT MERGE] prometheus: Add otel_scope_schema_url and otel_scope_[attribute] labels prometheus: Add otel_scope_schema_url and otel_scope_[attribute] labels May 22, 2025
@pellared pellared removed the blocked:specification Waiting on clarification of the OpenTelemetry specification before progress can be made label May 22, 2025
@jade-guiton-dd
Copy link

FYI: @mx-psi and I manually tested this PR in the Collector, and (as long as we disable without_scope_info, which is currently on by default in the Collector) it seems to resolve the conflicts we were having in open-telemetry/opentelemetry-collector#12939.

@pellared pellared merged commit 69f189f into open-telemetry:main May 24, 2025
29 checks passed
@pellared pellared deleted the prom-ident branch May 24, 2025 17:35
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 <[email protected]>
Co-authored-by: Carlos Alberto Cortez <[email protected]>
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 <[email protected]>
Co-authored-by: Carlos Alberto Cortez <[email protected]>
@MrAlias MrAlias added this to the v1.37.0 milestone Jun 18, 2025
pellared added a commit that referenced this pull request Jun 25, 2025
### Added

- The `go.opentelemetry.io/otel/semconv/v1.33.0` package.
The package contains semantic conventions from the `v1.33.0` version of
the OpenTelemetry Semantic Conventions.
See the [migration documentation](./semconv/v1.33.0/MIGRATION.md) for
information on how to upgrade from
`go.opentelemetry.io/otel/semconv/v1.32.0.`(#6799)
- The `go.opentelemetry.io/otel/semconv/v1.34.0` package.
The package contains semantic conventions from the `v1.34.0` version of
the OpenTelemetry Semantic Conventions. (#6812)
- Add metric's schema URL as `otel_scope_schema_url` label in
`go.opentelemetry.io/otel/exporters/prometheus`. (#5947)
- Add metric's scope attributes as `otel_scope_[attribute]` labels in
`go.opentelemetry.io/otel/exporters/prometheus`. (#5947)
- Add `EventName` to `EnabledParameters` in
`go.opentelemetry.io/otel/log`. (#6825)
- Add `EventName` to `EnabledParameters` in
`go.opentelemetry.io/otel/sdk/log`. (#6825)
- Changed handling of `go.opentelemetry.io/otel/exporters/prometheus`
metric renaming to add unit suffixes when it doesn't match one of the
pre-defined values in the unit suffix map. (#6839)

### Changed

- The semantic conventions have been upgraded from `v1.26.0` to
`v1.34.0` in `go.opentelemetry.io/otel/bridge/opentracing`. (#6827)
- The semantic conventions have been upgraded from `v1.26.0` to
`v1.34.0` in `go.opentelemetry.io/otel/exporters/zipkin`. (#6829)
- The semantic conventions have been upgraded from `v1.26.0` to
`v1.34.0` in `go.opentelemetry.io/otel/metric`. (#6832)
- The semantic conventions have been upgraded from `v1.26.0` to
`v1.34.0` in `go.opentelemetry.io/otel/sdk/resource`. (#6834)
- The semantic conventions have been upgraded from `v1.26.0` to
`v1.34.0` in `go.opentelemetry.io/otel/sdk/trace`. (#6835)
- The semantic conventions have been upgraded from `v1.26.0` to
`v1.34.0` in `go.opentelemetry.io/otel/trace`. (#6836)
- `Record.Resource` now returns `*resource.Resource` instead of
`resource.Resource` in `go.opentelemetry.io/otel/sdk/log`. (#6864)
- Retry now shows error cause for context timeout in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`,
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc`,
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`,
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`,
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`,
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#6898)

### Fixed

- Stop stripping trailing slashes from configured endpoint URL in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`.
(#6710)
- Stop stripping trailing slashes from configured endpoint URL in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`.
(#6710)
- Stop stripping trailing slashes from configured endpoint URL in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc`.
(#6710)
- Stop stripping trailing slashes from configured endpoint URL in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`.
(#6710)
- Validate exponential histogram scale range for Prometheus
compatibility in `go.opentelemetry.io/otel/exporters/prometheus`.
(#6822)
- Context cancellation during metric pipeline produce does not corrupt
data in `go.opentelemetry.io/otel/sdk/metric`. (#6914)

### Removed

- `go.opentelemetry.io/otel/exporters/prometheus` no longer exports
`otel_scope_info` metric. (#6770)
dmitryax added a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Jul 22, 2025
…1488)

Map `otel_scope_schema_url` label to OpenTelemetry ScopeMetrics schema
URL field. Emitting of the `otel_scope_schema_url` label was added in
open-telemetry/opentelemetry-go#5947
povilasv pushed a commit to coralogix/opentelemetry-collector-contrib that referenced this pull request Jul 29, 2025
…en-telemetry#41488)

Map `otel_scope_schema_url` label to OpenTelemetry ScopeMetrics schema
URL field. Emitting of the `otel_scope_schema_url` label was added in
open-telemetry/opentelemetry-go#5947
Dylan-M pushed a commit to Dylan-M/opentelemetry-collector-contrib that referenced this pull request Aug 5, 2025
…en-telemetry#41488)

Map `otel_scope_schema_url` label to OpenTelemetry ScopeMetrics schema
URL field. Emitting of the `otel_scope_schema_url` label was added in
open-telemetry/opentelemetry-go#5947
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:exporter:prometheus Related to the Prometheus exporter package

Development

Successfully merging this pull request may close these issues.

Prometheus exporter export instrumentation scope attributes

7 participants