-
Notifications
You must be signed in to change notification settings - Fork 880
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
Analysis of instrumentation customisation #1623
Comments
@pavolloffay Reading this text above ^^, are you still sure that you want to extend existing instrumentation class in your vendor distribution? |
I wanted to extend the core instrumentation to avoid repeating the
This is interesting and I think that there are benefits of removing attributes directly in the user app process to keep the volume of data low as early as possible. From the gitter channel:
|
For us to be on the same page: these are nice-to-have, but not required, right? Matcher methods are pretty small. And there is a trade-off between writing less code and have the danger of upstream instrumentation changes break your own instrumentation. |
You are right, it's fine to copy them over, on the new release there is a unit test to verify that it works anyways. Although some newly added matches to the core might be missed and not copied over. |
I have just updated to Java agent 0.10.0 in my custom build hypertrace/javaagent#120. In my custom servlet instrumentation I had to use servlet specific tracers to access the current span the
|
for others following here, this issue is continued over in #1661 (comment) |
Another use-case: extending instrumentation modules: #1677 |
Related to #566, #1622 and #778
I am going to summarise my current understanding of various options for overriding any given instrumentation in custom vendor distributions. The goal is not to arrive at an ideal solution, but at a solution good enough for GA. I focus on the following motivation for such customisation:
To simplify the following discussion, let me take as an example some database client instrumentation that creates a span for database call and extracts data from db connection to provide attributes for that span.
I don't want this span at all
The easiest case. You can just pre-configure your distribution and disable given instrumentation.
I want to add/modify some attributes and their values does NOT depend on a specific db connection instance.
E.g. you want to add some data from call stack as span attribute. In this case just provide your custom SpanProcessor. No need for touching instrumentation itself.
I want to add/modify some attributes and their values depend on a specific db connection instance.
Write a new instrumentation, which injects its own advice into the same method as the original instrumentation. Use
getOrder
method to ensure it is run after the original instrumentation. Now you can augment current span with new information.I want to remove some attributes
Write custom exporter or use attribute filtering functionality in Collector
I don't like Otel span at all. I want to significantly modify it and its lifecycle
Disable existing instrumentation. Write a new one, which injects Advice into the same (or better) method as the original instrumentation. Write your own Advice for this. Use existing Tracer directly or extend it. As you have your own Advice, you can control which Tracer you use.
======
The analysis above has some assumptions built-in. First, it assumes that custom instrumentation writer has access to the source code of the original instrumentation. They will have to copy-paste code from
transformers()
method of the original instrumentation. This means, among other things, that changes in the original instrumentation'stransformers
method may be breaking changes for custom instrumentation.Second, it assumes that Otel
TypeInstrumentations
are sufficiently fine-grained. If an instrumentation has a large number of advices packed into it, it may be difficult to replace just one of them.Also this analysis does not address the problem of changing a lot of similar instrumentations at once. E.g. "in all database client instrumentations add this extra attribute". This may be achieved by extending #778.
The text was updated successfully, but these errors were encountered: