-
Notifications
You must be signed in to change notification settings - Fork 869
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
Clarification on duplicated instrument names under different meters #2064
Comments
From API perspective this is totally fine.
It's currently documented here https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#view. |
But this is exactly one of my concerns from above. I'm not sure this should be a burden on the application developer/owner. If it's a responsibility on the library author, then I think we should make it clear that they need to append the Meter name to the instrument name to make it "unique" (or any other technique). I didn't find any guidance like this in the spec. The only thing I found was this in the Supplementary Guidelines:
Which doesn't really help much I think. In reality I think it's not far-fetched to assume users will have their own semantics that are relevant to their business/use-case which are not defined in the semantic conventions. But let's assume they all follow the conventions: We already have a problem here don't we? If they do follow the conventions they will end up with duplicate instrument names, unless something uses the meter name in the instrument at some point.
I'm confused. This is the instructions for views and I asked what should happen when no views are involved. I'm very fresh into metrics, so if it's something that I'm lacking I assume everyone that is also new to metrics using OTel will also face. In that link, there's a section:
And there's nothing saying that a view should be used to "solve" conflicting instrument names. It only has this:
This could all be that it's a "known concept" in the metrics space and since I'm new to all of this I have this hard time understanding it. But this is the exact point why we should clarify and make things better because I guess most of the target audience of OTel will also not have this knowledge. |
I agree with Joao that this is a bug in the implementation. From a library author perspective, I should be able to obtain a meter and be sure the name I use won't conflict with other libraries. The current spec states quite clearly that instruments with the same name created by different meters must not interfere with each other. To me, that means it is not up to the end-user application, but that this should be guaranteed by the API/SDK.
IMO this is unrelated. The behavior should not depend on the library author picking a "correct" semantic convention as the application developer may want to create custom metrics and there could always be cases where there is no semantic convention yet. |
Here are some related discussions #2035 (comment). |
See #2317. |
I believe this was addressed in #2317, please re-open if not. |
TL;DR
What should be the SDK behavior when two instruments with the same name are registered under different meters and no views are registered/involved?
The behavior in .NET is that the second instrument is dropped and never reaches the exporter. In Go, it seems we get errors (as per this Slack thread)
Long version
Hey all. I wanted to get my feet wet with OTel metrics, so I started by reading the metrics API and SDK specification. Then, I started playing around with the .NET SDK and I ran into some confusion around the instrument names. I have a long thread with @cijothomas and we were both a bit confused so I'm opening this so we can get some clarification.
Lets say we have this use-case:
We develop an app that records
request_count
(just as an example, could be anything). The app uses a third-party package that has its own meter and an instrument with the same name to record its ownrequest_count
.We now have two instruments with the same name, under different meters. This should be fine, as the API spec is clear on this:
This is also listed as a capability in the Compliance matrix of Implementations with the Specification:
So I went ahead and created a sample app to "simulate" this use case. You can find the code here.
It's a simple console app that imports a class lib to simulate the third-party package. The console app records on its own instrument first, then invokes a method on the library which records on its own instrument.
Both meters are registered in the Console app as:
When I run the sample app, I expected this output in the console:
But instead, I only saw this:
While debugging, I saw that the second instrument is dropped. There is a map of instrument names, and since the names are the same, the second is simply dropped. It never reaches the exporter.
The same thing happens if I use the OTLP exporter to export to a collector:
I started a discussion in the .NET slack channel and it was pointed out, that the API spec is clear, but that this does not mean the SDK is responsible for resolving/flattening the meter names (e.g., appending the meter name to the instrument to produce a "unique" metric stream name). I completely agree with that.
It was also mentioned, that Views should be used to "solve" this problem. The point was that I should use a View to "rename" the conflicting metric by providing a view with a custom name. This logic is defined in the SDK spec here.
The relevant portion is:
I read this multiple times and still can't wrap my head around it. What is confusing/not clear to me is
What if I don't use/want views?
In the statement above, the part "
View requires to export the metrics using a certain name, but the name is already used by another View
" is a bit confusing. To me, that refers to conflicting view names and not instrument names. For example: I created a view with nameview_a
and configured it to export instruments withrequest_*
. Then, I create another view, also calledview_a
, that also collectsrequest_*
. This leads to a a conflict, because although the instruments match for both views, my view conflicts with an existing one. In fact, the view names would clash, even if the instruments' names were different. To me, it is not clear whether this section refers to the view names (view_a
), or the instrument names (request_*
).Another thing that came up in the discussion was that there's limitations in the exporters. For example Prometheus does not support duplicated metric names. This makes sense to me, especially in this case. I expected the SDK to not drop the instruments due to duplicated names. However, this makes it the exporters' job to do whatever they need to to make it work. In this case, prepending the meter names to the instrument name, to make it "unique". But if the metric data never reaches the exporters in the first place, this is not possible.
This is particularly concerning to me, because as an application owner, I would expect:
So, in essence, what should be the SDK behavior when we have two instruments with the same name, registered under different meters, and no views involved? And if there's views involved, should the view name be used to check conflicts or the instrument names?
The text was updated successfully, but these errors were encountered: