OpenTelemetry Bot f0e9fdbe5d [release/v2.5.x] Prepare release 2.5.0 (#11597) | 6 месяцев назад | |
---|---|---|
.. | ||
agent | 8 месяцев назад | |
bootstrap | 2 лет назад | |
custom | 1 год назад | |
gradle | 7 месяцев назад | |
instrumentation | 10 месяцев назад | |
smoke-tests | 7 месяцев назад | |
testing | 8 месяцев назад | |
README.md | 1 год назад | |
build.gradle | 6 месяцев назад | |
gradle.properties | 2 лет назад | |
gradlew | 7 месяцев назад | |
gradlew.bat | 9 месяцев назад | |
settings.gradle | 2 лет назад |
This repository serves as a collection of examples of extending functionality of OpenTelemetry Java instrumentation agent. It demonstrates how to repackage the aforementioned agent adding custom functionality. For every extension point provided by OpenTelemetry Java instrumentation, this repository contains an example of its usage.
This repository has four main submodules:
custom
contains all custom functionality, SPI and other extensionsagent
contains the main repackaging functionality and, optionally, an entry point to the agent, if one wishes to
customize thatinstrumentation
contains custom instrumentations added by vendorsmoke-tests
contains simple tests to verify that resulting agent builds and applies correctlyIdGenerator
TextMapPropagator
Sampler
SpanProcessor
SpanExporter
There are several options to override or customise instrumentation provided by the upstream agent. The following description follows one specific use-case:
Instrumentation X from Otel distribution creates span that I don't like and I want to change it in my vendor distro.
As an example, let us take some database client instrumentation that creates a span for database call and extracts data from db connection to provide attributes for that span.
The easiest case. You can just pre-configure your distribution and disable given instrumentation.
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.
Write a new instrumentation which injects its own advice into the same method as the original one.
Use getOrder
method to ensure it is run after the original instrumentation.
Now you can augment current span with new information.
See DemoServlet3Instrumentation.
Write custom exporter or use attribute filtering functionality in Collector.
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.