-
Notifications
You must be signed in to change notification settings - Fork 896
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
Handle instrumentation scope in the Prometheus conversion spec #2422
Conversation
abb65d2
to
0a5973f
Compare
specification/metrics/datamodel.md
Outdated
Instrumentation Scope MUST be left unset for metrics scraped from Prometheus | ||
endpoints. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the opentelemetry_instrumentation_scope
info metric is present that that not be used for the instrumentation scope?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats correct. It remains a separate metric stream to transmit that a given instrumentation library was used, but it doesn't allow you to figure out which metrics it applies to. I'm not sure it makes much sense, though, without the "short_name" in instrumentation scope. If we had that, then we could reconstruct the Instrumentation Scope here.
Maybe I should just skip this intermediary specification step, and just propose the "short_name" + round-tripping through prometheus...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should just skip this intermediary specification step, and just propose the "short_name" + round-tripping through prometheus...
I'd be interested to hear what other think, but that sounds good to me.
We should be careful to call the OpenMetrics "metric namespace" an equivalent of OTel's instrumentation library. I don't think this is completely true, see below. Proposal for round-tripping Instrumentation ScopeI would like to see a treatment of instrumentation scope that could preserve the information for an OTel SDK exporting Prometheus data, which means a Prometheus scrape ideally would produce the same metrics as the SDK would have pushed. I think this is possible. I've studied the OpenMetrics guidance on target info, and consider instrumentation scope information to be in a similar category. Suppose we use an OM info metric:
To round-trip this correctly with an OTel scraper, an OTel SDK would specifically produce one library of metrics at a time. The OM/OTel translation would infer that metrics are organized by instrumentation scope such that the most recent Argument in favor of a first-class namespace conceptOpenMetrics writes about metric namespacing "the aim is to keep to a lightweight informal approach" and has three standard instrument constructor fields: "Namespace", "Subsystem", and "Name". With two optional underscore-separated fields and the potential for "Name" itself to contain underscores, there's no way to parse an OM metric name and infer what is namespace, what is subsystem, and what is name. Given no way to distinguish these, "metric namespace" appears to be a user-level option to ensure that when the same kind of instrumentation is produced by multiple distinct instances of the same instrumentation inside a single process, the user can force them not to aggregate or display in the same queries by adding an additional prefix. This would be done as-needed when the user is aware of conflicts and has the intention to solve them using namespaces, otherwise would not be done to keep metric names short. To illustrate when metric namespace appears to solve for an OM user, imagine an OTel SDK configured with two clients speaking to two separate Redis instances with different load patterns, different kinds of data, different purposes. You've got two instances of the Redis client, and two instances of the OTel instrumentation. Can the user have a way to distinguish the two scopes that works for both OM and OTel? IMO the user needs a first-class namespace concept here, which is not what OTel's instrumentation scope is at this time. Adding an additional property or property list to the Instrumentation Scope message type could help, and we could extend the OM<->OTel translation rules, for example, as follows. Suppose the This is what two instrumentation scopes for the same instrumentation library would look like when scraped, using the OM metric namespace:
|
Unfortunately, I don't think the "Proposal for round-tripping Instrumentation Scope" complies with the OM spec: I haven't actually ever seen Namespace used to distinguish multiple instances of instrumentation--people just seem to use it as a second "subsystem" (e.g. in k8s), but maybe they were just using it wrong :). Since prom doesn't have a "View" concept, all metrics i've seen are fully named (including namespace, subsystem, etc.) by the library itself. I think this is implied by the OM spec as well: So I think we are roughly on the same page, but need to figure out if the OM namespace is the equivalent of the instrumentation library, or if it is meant to be more than that. @brian-brazil, we discussed this briefly at the prom WG yesterday. Can you help clarify the purpose of the OM namespace? |
I see no problems with the sample output. Though name and version are poor choices of label name that are highly likely to clash with something.
There's no formal concept of it in OM, as you say namespacing is performed by the library to keep it from colliding with other libraries. |
I see. A workaround would be to namespace the
|
OM has no such fields or notiions, that's what some client libraries did historically and I personally now consider it a bad idea. At the least it breaks grepability of metric names. |
I updated this to propose the short_name. |
This proposal from @bogdandrutu #2307 would give us a nice place to store the new "short_name" concept. I'm eager to see us add a list of arbitrary key:values to the scope, it would give us a way to distinguish two instances of the same instrumentation library which today we cannot do. |
+1 to this. There are other use cases for this key:value list in the scope too, such as differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. |
Given the comments about key-value lists in the Scope should the addition of ShortName be paused for now and instead we make it a semantic convention to be recorded in the key-value list? |
Yes. I'll close this for now, and will reopen after we've introduced the key-value list. |
There are a few reasons why Scope attributes are a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
There are a few reasons why Scope attributes are a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
There are a few reasons why Scope attributes are a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
There are a few reasons why Scope attributes are a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
There are a few reasons why adding Scope attributes are a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
There are a few reasons why adding Scope attributes is a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
There are a few reasons why adding Scope attributes is a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
There are a few reasons why adding Scope attributes is a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
There are a few reasons why adding Scope attributes is a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
There are a few reasons why adding Scope attributes is a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
There are a few reasons why adding Scope attributes is a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
* Introduce Scope Attributes There are a few reasons why adding Scope attributes is a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
@tigrannajaryan @dashpole now that we have the scope attributes, should we bring this topic back, and define the semantic convention for scope attribute(s), where |
Yes, feel free to make a proposal (or @dashpole feel free to do it). We may need changes to semantic convention generator tooling to support scopes. |
Unfortunately I don't have the cycles to work on this now, but I quickly tried it out and I think we don't need to change the convention generator. Here's what I tried: We could have a document inside |
@dashpole will you be able to work on this? |
Yes, I plan to work on this |
Do we have an issue for it? Also, do you folks have an idea on how would we name this? We already have this page that states |
I don't think anything is decided yet. I would not assume |
Yeah I don't particularly have any answers, but was rather fishing for your ideas. I think we probably should have a new issue to discuss this topic further and lay out a good foundation for other attributes to come. I also don't think we need |
I created an issue #2682 so we have a forum to discuss it. :) |
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.
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.
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.
* Introduce Scope Attributes There are a few reasons why adding Scope attributes is a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry#2450).
* Introduce Scope Attributes There are a few reasons why adding Scope attributes is a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
* Introduce Scope Attributes There are a few reasons why adding Scope attributes is a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
* Introduce Scope Attributes There are a few reasons why adding Scope attributes is a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](open-telemetry/opentelemetry-specification#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](open-telemetry/opentelemetry-specification#2450).
* Introduce Scope Attributes There are a few reasons why adding Scope attributes is a good idea: - There are 2 known use cases where Scope attributes can solve specific problems: - Add support for [Meter "short_name"](#2422), represented as an attribute of Meter's Scope. - Add support for differentiating the type of data emitted from the scopes that belong to different data domains, e.g. profiling data emitted as log records or client-side data emitted as log records needs to be differentiated so that it can be easily routed and processed differently in the backends. We don't have a good way to handle this today. The type of the data can be recorded as an attribute Logger's Scope. - It makes Scope consistent with the other primary data types: Resource, Span, Metric, LogRecord. See additional [discussion here](#2450).
Related: #1906
Background
OpenMetrics Naming+Namespacing
Changes
This adds "short_name" to the instrumentation scope, which would be an optional, single-word name for the scope. If present, it would be used as the metric prefix in Prometheus exporters. In prometheus receivers, the
opentelemetry_instrumentation_scope
metric would identify prefixes that can be removed from metrics, and used to reconstruct the Instrumentation scope in OTLP.Alternatives:
goopentelemetryiocontribinstrumentationnethttpotelhttp_http_server_duration
cc @jmacd @Aneurysm9 @jsuereth