1

I read the Sleuth docs, but i didn't find informations about change default parameter name "traceId" or "spanId". Is it possible without adding extra fields?

@Override
public void doFilter(ServletRequest request, ServletResponse response,
                     FilterChain chain) throws IOException, ServletException {
    Span currentSpan = this.tracer.currentSpan();
    if (currentSpan == null) {
        chain.doFilter(request, response);
        return;
    }

    currentSpan.customizer().tag("correlationId", currentSpan.context().spanIdString());

    chain.doFilter(request, response);
}
vertenon
  • 23
  • 5

2 Answers2

0

You would have to create your own implementation of the Propagation bean. The default is B3Propagation. You can check the default implementation here https://github.com/openzipkin/brave/blob/5.8.0/brave/src/main/java/brave/propagation/B3Propagation.java

Marcin Grzejszczak
  • 10,624
  • 1
  • 16
  • 32
-1

U can use this migration document to rename slueth traceid to anything else.The documentation allow u to rename traceId to anything else by creating a bean decorator

 @Bean ScopeDecorator legacyIds() {
  return MDCScopeDecorator.newBuilder()
                         .clear()
                         .add(SingleCorrelationField.newBuilder(BaggageFields.TRACE_ID)
                                                    .name("X-B3-TraceId").build())
                         .add(SingleCorrelationField.newBuilder(BaggageFields.PARENT_ID)
                                                    .name("X-B3-ParentSpanId").build())
                         .add(SingleCorrelationField.newBuilder(BaggageFields.SPAN_ID)
                                                    .name("X-B3-SpanId").build())
                       .add(SingleCorrelationField.newBuilder(BaggageFields.SAMPLED)
                                                    .name("X-Span-Export").build())
                         .build();
}

https://github.com/spring-cloud/spring-cloud-sleuth/wiki/Spring-Cloud-Sleuth-3.0-Migration-Guide#x-b3--mdc-fields-names-are-no-longer-set

Kumar Shanoo
  • 125
  • 4