Skip to content
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

How to map the Meter name in non-OTLP exporters? #1906

Open
arminru opened this issue Sep 6, 2021 · 5 comments
Open

How to map the Meter name in non-OTLP exporters? #1906

arminru opened this issue Sep 6, 2021 · 5 comments
Assignees
Labels
area:semantic-conventions Related to semantic conventions spec:metrics Related to the specification/metrics directory

Comments

@arminru
Copy link
Member

arminru commented Sep 6, 2021

In the Tracing SDK spec we have specified the following mapping for the Tracer name and version (= InstrumentationLibrary name/version) for non-OTLP exporters:

OpenTelemetry InstrumentationLibrary's fields MUST be reported as key-value
pairs associated with the Span using the following mapping:

OpenTelemetry InstrumentationLibrary Field non-OTLP Key
InstrumentationLibrary.name otel.library.name
InstrumentationLibrary.version otel.library.version

The Metrics API specifies the Meter name and version accordingly. In OTLP this is reported as InstrumentationLibrary as well.

Should we define the same mapping for non-OTLP metrics exporters as well, i.e., should the meter name and version be added as attributes/labels/tags/dimensions called otel.library.name and otel.library.version, or would it make more sense to call this otel.meter.* here? This would be inconsistent with the Tracing spec, however, since that one could have also just called it otel.tracer.* but didn't.
I'd be in favor of staying consistent here, even though seeing otel.library.* on the backend might not be as obvious to the user as the more "tangible" notation of a "Meter name".

@arminru arminru added area:sdk Related to the SDK area:semantic-conventions Related to semantic conventions spec:metrics Related to the specification/metrics directory labels Sep 6, 2021
@Oberon00
Copy link
Member

Oberon00 commented Sep 7, 2021

I think this old discussion is related: #434

@reyang reyang added this to the Metrics API/SDK Feature Freeze milestone Sep 8, 2021
@jsuereth
Copy link
Contributor

jsuereth commented Sep 14, 2021

Metric exporters suffer more greatly from limited attribute labels vs. tracing.

If we specify that this CAN be reported, it's ok. If we specify it MUST be reported, we're causing problems for our users.

Specifically, for fields the "vary" a lot. Here's a good article on prometheus-related issues, and evaluation of alternative metric tsdbs

I think requiring instrumentation library version MAY be a bit too far for a prometheus ecosystem, but the library name might be ok.

Point being Labels for Metrics need more care than they did for Trace, and we should evaluate appropriately.

@arminru
Copy link
Member Author

arminru commented Sep 15, 2021

@jsuereth Making the name a SHOULD or CAN is fine with me. For the version we could add some guidance that it might be unnecessary in most situations but still define the attribute key so it's used consistently in case someone decides to report it.

hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 19, 2021
* Add `OTEL_METRICS_LIBRARY_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 19, 2021
* Add `OTEL_METRICS_LIBRARY_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 21, 2021
* Add `OTEL_METRICS_LIBRARY_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 21, 2021
* Add `OTEL_METRICS_LIBRARY_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 21, 2021
* Add `OTEL_EXPORTER_PROMETHEUS_LIBRARY_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 21, 2021
* Add `OTEL_EXPORTER_PROMETHEUS_LIBRARY_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 23, 2021
* Add `OTEL_EXPORTER_PROMETHEUS_LIBRARY_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 23, 2021
* Add `OTEL_EXPORTER_PROMETHEUS_LIBRARY_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 25, 2021
* Add `OTEL_EXPORTER_PROMETHEUS_LIBRARY_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 25, 2021
* Add `OTEL_EXPORTER_PROMETHEUS_LIBRARY_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
@reyang reyang removed the area:sdk Related to the SDK label Oct 25, 2021
@reyang
Copy link
Member

reyang commented Oct 25, 2021

The Metrics SDK part is addressed by #2040. There is also the semantic convention part and Prometheus Exporter part, so keep the issue open.

@reyang reyang removed their assignment Oct 25, 2021
@reyang reyang removed this from the Metrics API/SDK Feature Freeze milestone Oct 25, 2021
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 25, 2021
* Add `OTEL_EXPORTER_PROMETHEUS_LIBRARY_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 26, 2021
* Add `OTEL_EXPORTER_PROMETHEUS_LIBRARY_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 27, 2021
* Add `OTEL_EXPORTER_PROMETHEUS_ADD_METER_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
hdost added a commit to criteo-forks/opentelemetry-specification that referenced this issue Oct 27, 2021
* Add `OTEL_EXPORTER_PROMETHEUS_ADD_METER_ATTRIBUTES` variable
* Update Metric SDK to clarify when Meter attributes should be exported.

Fixes open-telemetry#1906

Signed-off-by: Harold Dost <h.dost@criteo.com>
@arminru
Copy link
Member Author

arminru commented Feb 9, 2022

Note that with #2276 the attribute keys for the tracer name will be changed to otel.scope.name and otel.scope.version and should then also be used for the meter name alike.

tigrannajaryan pushed a commit that referenced this issue Oct 12, 2022
Fixes: #2493

Related: #1906

This is a second attempt at #2422.

## Changes

### Background: Naming Collisions

OpenTelemetry encourages the use of semantic conventions to make metric naming similar across instrumentation.  For example, if I have two http client libraries in my application, they would each produce a metric named `http.client.duration`, but with different meters (e.g. [otelmux](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/0dd27453a1ce8e433cb632e175a27f28ee83998d/instrumentation/github.com/gorilla/mux/otelmux) vs [otelhttp](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/0dd27453a1ce8e433cb632e175a27f28ee83998d/instrumentation/net/http/otelhttp)).  A prometheus exporter which receives both of these metrics would not be able to serve both of those histograms.  This would occur anytime a user uses two libraries which produces the same category (e.g. http, database, rpc, etc) of metrics, or if the two libraries just happen to use the same name for a metric.  Depending on the language, it may fail to create the Prometheus exporter, or may fail to send some, or all metrics if the same labels keys and values are present in both.

### Desired User Experience

As a user, I can use a Prometheus exporter with OpenTelemetry without experiencing strange errors/behavior due to naming collisions, and without having to apply transformations to metric names to work around these, except in rare cases.

As a user, I can easily add scope attributes to my metrics in Prometheus by joining with an info-style metric.  This is a common pattern in Prometheus: https://grafana.com/blog/2021/08/04/how-to-use-promql-joins-for-more-effective-queries-of-prometheus-metrics-at-scale/.

### Design

Add `opentelemetry_scope_name` and `opentelemetry_scope_version` as labels to all metrics.  This ensures that if two libraries produce the same metric points, they don't collide because the scope name/version labels will differ.

Those labels also serve as "join keys" to be able to add scope attributes to Prometheus metrics.  This is accomplished by introducing an `opentelemetry_scope_info` metric containing the same `opentelemetry_scope_name` and `opentelemetry_scope_version` labels, but also including scope attributes.  This also enables the collector's Prometheus receiver to reconstruct the original Instrumentation Scope when receiving the metrics.
ChengJinbao added a commit to ChengJinbao/opentelemetry-specification that referenced this issue Nov 16, 2022
Fixes: #2493

Related: open-telemetry/opentelemetry-specification#1906

This is a second attempt at open-telemetry/opentelemetry-specification#2422.

## Changes

### Background: Naming Collisions

OpenTelemetry encourages the use of semantic conventions to make metric naming similar across instrumentation.  For example, if I have two http client libraries in my application, they would each produce a metric named `http.client.duration`, but with different meters (e.g. [otelmux](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/0dd27453a1ce8e433cb632e175a27f28ee83998d/instrumentation/github.com/gorilla/mux/otelmux) vs [otelhttp](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/0dd27453a1ce8e433cb632e175a27f28ee83998d/instrumentation/net/http/otelhttp)).  A prometheus exporter which receives both of these metrics would not be able to serve both of those histograms.  This would occur anytime a user uses two libraries which produces the same category (e.g. http, database, rpc, etc) of metrics, or if the two libraries just happen to use the same name for a metric.  Depending on the language, it may fail to create the Prometheus exporter, or may fail to send some, or all metrics if the same labels keys and values are present in both.

### Desired User Experience

As a user, I can use a Prometheus exporter with OpenTelemetry without experiencing strange errors/behavior due to naming collisions, and without having to apply transformations to metric names to work around these, except in rare cases.

As a user, I can easily add scope attributes to my metrics in Prometheus by joining with an info-style metric.  This is a common pattern in Prometheus: https://grafana.com/blog/2021/08/04/how-to-use-promql-joins-for-more-effective-queries-of-prometheus-metrics-at-scale/.

### Design

Add `opentelemetry_scope_name` and `opentelemetry_scope_version` as labels to all metrics.  This ensures that if two libraries produce the same metric points, they don't collide because the scope name/version labels will differ.

Those labels also serve as "join keys" to be able to add scope attributes to Prometheus metrics.  This is accomplished by introducing an `opentelemetry_scope_info` metric containing the same `opentelemetry_scope_name` and `opentelemetry_scope_version` labels, but also including scope attributes.  This also enables the collector's Prometheus receiver to reconstruct the original Instrumentation Scope when receiving the metrics.
joaopgrassi pushed a commit to dynatrace-oss-contrib/semantic-conventions that referenced this issue Mar 21, 2024
Fixes: #2493

Related: open-telemetry/opentelemetry-specification#1906

This is a second attempt at open-telemetry/opentelemetry-specification#2422.

## Changes

### Background: Naming Collisions

OpenTelemetry encourages the use of semantic conventions to make metric naming similar across instrumentation.  For example, if I have two http client libraries in my application, they would each produce a metric named `http.client.duration`, but with different meters (e.g. [otelmux](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/0dd27453a1ce8e433cb632e175a27f28ee83998d/instrumentation/github.com/gorilla/mux/otelmux) vs [otelhttp](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/0dd27453a1ce8e433cb632e175a27f28ee83998d/instrumentation/net/http/otelhttp)).  A prometheus exporter which receives both of these metrics would not be able to serve both of those histograms.  This would occur anytime a user uses two libraries which produces the same category (e.g. http, database, rpc, etc) of metrics, or if the two libraries just happen to use the same name for a metric.  Depending on the language, it may fail to create the Prometheus exporter, or may fail to send some, or all metrics if the same labels keys and values are present in both.

### Desired User Experience

As a user, I can use a Prometheus exporter with OpenTelemetry without experiencing strange errors/behavior due to naming collisions, and without having to apply transformations to metric names to work around these, except in rare cases.

As a user, I can easily add scope attributes to my metrics in Prometheus by joining with an info-style metric.  This is a common pattern in Prometheus: https://grafana.com/blog/2021/08/04/how-to-use-promql-joins-for-more-effective-queries-of-prometheus-metrics-at-scale/.

### Design

Add `opentelemetry_scope_name` and `opentelemetry_scope_version` as labels to all metrics.  This ensures that if two libraries produce the same metric points, they don't collide because the scope name/version labels will differ.

Those labels also serve as "join keys" to be able to add scope attributes to Prometheus metrics.  This is accomplished by introducing an `opentelemetry_scope_info` metric containing the same `opentelemetry_scope_name` and `opentelemetry_scope_version` labels, but also including scope attributes.  This also enables the collector's Prometheus receiver to reconstruct the original Instrumentation Scope when receiving the metrics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:semantic-conventions Related to semantic conventions spec:metrics Related to the specification/metrics directory
Projects
None yet
5 participants