Creating Span Links in Auto Instrumentation - How to use a custom Tracer? #6082
-
I am attempting to create a span Link after context propagation based on some vendor passing a Trace ID and Span ID the TraceState. As I understand the only way this is possible in the Java SDK is to create the Link when the Span starts. Therefore, in order for auto instrumentation to be able to create span links generically, I would need to create a custom Tracer , TracerProvider, and SpanBuilder and configure the Instrumenter API to use these somehow. I can't find any way to set the TracerProvider when using auto instrumentation with an extension jar. There is an addTracerProviderCustomizer in the class AutoConfigurationCustomizerProvider and an example of how to use it in the extensions example project, but this configures an SdkTracerProvider, so I'm not sure its even possible to change the auto configuration to do this. Is there any way that I am missing that I could register a default Tracer? Or is it possible to add a SpanLinksExtractor to all server Instrumenters automatically? For reference, I have been testing with the 1.13.0 agent and API. Would appreciate any help, thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
hi @noctchillin! this is going to be tricky. There are spec discussions to relax the requirement that span links are only added at span start, but not certain how this will end up. I'd recommend either creating a child span with the links, or creating a span event with trace_id/span_id attributes. Another option could be to add trace_id/span_id attributes on the auto instrumented span, and use a custom exporter to translate that back to span links before passing on to your (otlp?) exporter |
Beta Was this translation helpful? Give feedback.
hi @noctchillin! this is going to be tricky. There are spec discussions to relax the requirement that span links are only added at span start, but not certain how this will end up.
I'd recommend either creating a child span with the links, or creating a span event with trace_id/span_id attributes.
Another option could be to add trace_id/span_id attributes on the auto instrumented span, and use a custom exporter to translate that back to span links before passing on to your (otlp?) exporter