Extensions are designed to override or customize the instrumentation provided by the upstream agent without having to create a new OpenTelemetry distribution or alter the agent code in any way.
Consider an instrumented database client that creates a span per database call and extracts data from the database connection to provide span attributes. The following are sample use cases for that scenario that can be solved by using extensions:
SpanProcessor
.order
method to ensure it runs after the original instrumentation and augment the current span
with new information.Advice
into the
same (or a better) method as the original instrumentation. You can write your Advice
for this and use the existing
Tracer
directly or extend it. As you have your own Advice
, you can control which Tracer
you use.To get a demonstration how to create an extension for the OpenTelemetry Java instrumentation agent, build and run the extension project.