openzipkin / zipkin-js

Zipkin instrumentation for Node.js and browsers
Apache License 2.0
565 stars 171 forks source link

zipkin-instrumentation-axiosjs not preserving traceId #528

Closed josephearl closed 3 years ago

josephearl commented 3 years ago

I have an express app endpoint which

  1. Logs a message with tracer.id.traceId
  2. Makes a request to an external service using wrapped axios
  3. Logs a message after receiving the response from the external service with tracer.id.traceId (and then returns a response)

What I observe:

  1. Logs traceId 9bc2310170da41b7
  2. Sends a different traceId 20279d8dee59e693 in the header x-b3-traceid
  3. Logs traceId 69a69d5fec3547cd

What I expect:

External service receives traceId 9bc2310170da41b7, log after receiving response has same traceId 9bc2310170da41b7 (it is all part of the same trace)

Same tracer instance is shared between expressMiddleware and wrapAxios.

josephearl commented 3 years ago

Fixed by using CLSContext