openzipkin / brave

Java distributed tracing implementation compatible with Zipkin backend services.
Apache License 2.0
2.36k stars 713 forks source link

Trace id is not Propagating to called service #1368

Open RoopaRJ opened 1 year ago

RoopaRJ commented 1 year ago

when i am calling another microservice using resttemplate it is working fine but when i tried with httpclient/webclient trace id is not propagating to the next service. example: in logs for service a it is showing traceid1, in service b it is showing traceid2 ideally we should get same trace id's in for the entire journey of a single request

below are the dependencies used in my springboot3 application for distributed tracing: implementation platform('io.micrometer:micrometer-tracing-bom:latest.release') implementation 'io.micrometer:micrometer-tracing-bridge-brave' implementation 'io.zipkin.reporter2:zipkin-reporter-brave' implementation 'io.zipkin.reporter2:zipkin-sender-urlconnection' implementation("org.springframework.boot:spring-boot-starter-webflux:3.0.5")

in application.yml i have added: zipkin: tracing: endpoint: http://localhost:9411/api/v2/spans

i am autowiring the Tracer to create spans like below: tracer.spanBuilder().name("randomSpan").start()

this is how i am calling another service using webclient: webClient.post() .uri(URI.create("url")) .contentType(MediaType.APPLICATION_JSON) .header("X-B3-TraceId", tracer.currentTraceContext().context().traceId()) .body(BodyInserters.fromValue(body)) .retrieve() .bodyToMono(java class) .block()