-
Notifications
You must be signed in to change notification settings - Fork 863
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
Allow attributes on a Tracer #7101
Comments
I suspect that this is bound to be tricky for a few reasons, not the least of which is a specification api (unless that already exists, which the above linked issue alludes to, I haven't checked). All "components" in the sdk are cached in the ComponentRegistry to facilitate reuse instead of recreating things. These components are stored by name -- so it isn't really possible (practical?) to have more than one instance of the same kind of tracer with the same name. In your case, it sounds like you are (or want to) create multiple tracers of the same type but with different attributes. Unfortunately, I think the design doesn't really afford this. In the hack above, I think (please maintainers correct me if I'm wrong) that you are mutating the single instrumentation scope instance for a single tracer instance. I suspect that same tracer is used across multiple LDAP requests, and when you're changing those attributes you're changing it in a scope larger than you expect. That's my quick $0.02. I do like this idea though, just not sure how to get there. I don't think a setter is enough. |
hi @JnRouvignac, is this a duplicate of #4695? |
Hi @trask, Yes! #4695 looks like a more general issue which covers what I am asking for here indeed. Anyway, also note that the current issue is more use case oriented, and it also highlights a potential memory leaks issues with the Based on this observation, I don't know how you would like to deal with the current issue? |
There is something very important that I'd like to point out: this use case equally applies to HTTP/2 connections. Therefore, they can hit the exact same problem of repeating the same attributes in request spans. I think this raises the priority of the use case reported here. |
@breedx-splk Thanks for taking the time to analyze the use case, and write an answer!
All the connections are identified by aconnection ID, so I was thinking that maybe we could use it as the I am not sure if this is a correct use because I have not fully understood the design around the
Yes, I fully agree, this does not work for the use case that I presented. Well spotted. Alas in that case, the |
It looks like the |
Is your feature request related to a problem? Please describe.
I am working on an LDAP server and I want to add attributes to my traces.
There are several level of attributes:
In LDAP, connections are persistent, and several requests can be multiplexed on the same connection.
Therefore repeating connections attributes in every request spans is a waste of bandwidth for the span exporter.
Describe the solution you'd like
Similar to #4473, I was thinking it would be interesting to add attributes to "instrumentation scope", i.e. at the tracer level. This would require creating one tracer per connection.
Problem is we have not been able to find an API to do that opentelemetry-sdk-trace :)
Describe alternatives you've considered
For the moment, connection attributes are duplicated into each span's attributes, but this is not ideal for bandwidth of the span exporter.
Using reflection we have been able to hack the internal fields, and we verified the connection attributes are no longer duplicated in each span:
The current internal API has all the plumbing needed, except it's missing a public API to set the attributes:
Additional context
Given that some LDAP connections are long lived, while some others are not (some clients open a connection, send a request, then close the connection), I have become worried that
ComponentRegistry
will become a memory leak over time because it has no flushing mechanism in place to remove metadata for old unused tracers.The text was updated successfully, but these errors were encountered: