java-spring-jaeger
java-spring-jaeger copied to clipboard
Custom name for trace-id
Hi!
Is there way to configure opentracing-spring-jaeger-cloud-starter
to handle any other header than Uber-Trace-Id
? I have Traefik as an ingress in my kubernetes cluster. Traefik can be configured to change traceContextHeaderName
. Default value is "uber-trace-id"
. When I change it to some custom, there is no connection between services. I believe that opentracing works only with Uber-Trace-Id
. Is there way to configure that?
Thanks for help!
Hello,
I am personally not aware of something, but @pavolloffay is the expert on the subject
I found culprit: io.jaegertracing.internal.propagation.TextMapCodec
in jaeger-core
dependency.
There is private constant private static final String SPAN_CONTEXT_KEY = "uber-trace-id";
. I believe we stuck with this. :(
The context key is configurable on the builder inside the codec https://github.com/jaegertracing/jaeger-client-java/blob/88a849722d7056557a2643330737967d77b87f88/jaeger-core/src/main/java/io/jaegertracing/internal/propagation/TextMapCodec.java#L246.
This lib could use that builder and allow consumers to modify it before constructing the tracer.
Temporary solution:
@Bean
public TracerBuilderCustomizer useCustomTraceIdHeader() {
TextMapCodec httpCodec = TextMapCodec.builder()
.withUrlEncoding(true)
.withObjectFactory(new JaegerObjectFactory())
.withSpanContextKey(CUSTOM_TRACE_ID)
.build();
return builder -> builder
.registerInjector(HTTP_HEADERS, httpCodec)
.registerExtractor(HTTP_HEADERS, httpCodec);
}