-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[connector/spanmetrics] Support multiple instrumentation scopes #30678
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Hello @fstab, it looks like this was an intentional design decision to show that the metrics are being generated from incoming spans in the connector. Context in this issue and the PR for it. Would it work for you to use the |
Thanks @crobert-1. I don't see how to solve this with
The only way I can see to differentiate multiple instrumentation scopes is to produce spanmetrics with different instrumentation scopes when the incoming spans have different instrumentation scopes. I also think this issue will become increasingly relevant over time. Maybe today having an eBPF-based instrumentation for a service that's also instrumented with an SDK is an uncommon scenario. However, more and more application frameworks are adding built-in OpenTelemetry support (like Java's Spring Boot for example), and thus duplications of built-in instrumentation and auto-instrumentation will become more common. As I understand it instrumentation scope is intended to differentiate between multiple instrumentations in these cases. |
An alternative would be to prefix the original instrumentation scope name, something like
That way we would not reuse the original scope, but still produce different scopes if there are multiple different original scopes. |
Hi I opened the issue about resource attributes and I didn't give scopes much thought tbh. I am not sure setting the scope name to I think the namespace is much better place to indicate where the metrics are coming from rather than using use OTel scopes. |
As you said Thanks to instrumentation scopes that is not an issue: The spans will have different scopes, and we can use that in the monitoring backend to distinguish these spans The key problem is that the spanmetrics processor cannot directly access span instrumentation scopes. Have you tried the transform:
error_mode: ignore
trace_statements:
- context: span
statements:
- set(attributes["scope.name"], instrumentation_scope.name)
- set(attributes["scope.version"], instrumentation_scope.version) then you can add the two span attributes into spanmetrics's @fstab hope it can help you. |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
This issue has been closed as inactive because it has been stale for 120 days with no activity. |
Isn't that the issue to fix? The This is how Datadog trace stats work
Needing to use the |
Component(s)
connector/spanmetrics
Is your feature request related to a problem? Please describe.
OpenTelemetry has the concept of instrumentation scopes. In most cases, the instrumentation scope is the name and version of the Instrumentation Library.
Here's an example where this is particularly useful: We have an eBPF-based auto-instrumentation tool that produces HTTP spans. However, if an application is already instrumented with an OTel SDK on the on the application level we get duplicate spans: Spans from the OTel SDK and spans from the eBPF tool. Thanks to instrumentation scopes that is not an issue: The spans will have different scopes, and we can use that in the monitoring backend to distinguish these spans.
Now, the spanmetrics connector does not keep the original instrumentation scope, but replaces it with a hard-coded scope name
spanmetricsconnector
. As a result, spans with different scopes are collapsed into the same spanmetrics leading to incorrect results when multiple libraries / tools instrument the same calls.I think this is the line where the hard-coded
spanmetricsconnector
scope is coming from: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/connector/spanmetricsconnector/connector.go#L257-L258Describe the solution you'd like
Keep the original instrumentation scope when producing span metrics.
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: