-
Notifications
You must be signed in to change notification settings - Fork 845
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
Support for subclassing instrumentation Tracers in custom distributions #778
Comments
I can work on this, but first I would like to clarify what would be the best approach. Would each instrumentation define SPI to get its tracer or just an SPI to load the BaseTracer? Ideally the tracer subclasses should access typed request/response objects. |
Great! My first thought would be SPI lookup for each tracer, e.g. It's a bit odd to use SPI lookup for a (non-abstract) class though. And a complication is that we'll need to inject the subclass as a "helper class", and any other classes that it brings along with it (e.g. anonymous inner classes). So maybe a separate SPI makes sense for loading these kinds of customizations, that can return the normal tracer class name, the subclass to use instead, and a list of helper classes to inject along with the subclass. We could load all of these SPI classes at agent init (they can live in AgentClassLoader) and build a map with an instrumentation API on top of the map that all the instrumentation use to inject extra helper classes and instantiate their tracers (which will happen in the user class loader). |
Yes I wanted to avoid doing this, but I cannot think of a better approach. So we will define an SPI for all tracer classes. We can add support gradually, one by one. |
Oh, there's a second proposal above that wasn't clear. E.g. create a single SPI interface something like:
And use ServiceLoader to load as many of these as are present during agent init and build a map keyed on tracer class name. And add a method to instrumentation api, e.g.:
that will check for one of these custom tracers and first, inject the helper classes, and instantiate and return custom tracer instead |
I get it now, do you think there can be any perf overhead at agent start time? |
always 😄, though I think this is probably a small worry relative to other agent init work |
@iNikem @anuraaga any opinions on this? If no I would like to start working on @trask's proposal from #778 (comment) |
I like the idea of having SPI for overriding Tracers. I like the idea of having just one SPI to override any tracer and not one per tracer. I am not sure that using tracer class name is the best way to identify tracer to be overridden. We may try and see how this will come out :) I wonder, how will this work with tracers hierarchies? E.g. this will not allow overriding Also, should we define extension points for tracers? E.g. we have more or less standard |
+1 to having one SPI to override any tracer rather than per-tracer, it seems a bit simpler to me. But seems like a good approach to me.
+10 |
Closing, we are going a different direction to provide this functionality (#2596) |
Use some kind of lookup (SPI) to instantiate the instrumentation Tracer singletons so that they can be subclassed in custom distributions.
This will enable people to capture additional attributes from standard Request/Response type objects, e.g. #566 (comment), #776 (comment)
A similar hook has proven useful in Brave per @anuraaga 👍.
The text was updated successfully, but these errors were encountered: