Jake Walsh
Jake Walsh

Reputation: 3869

Open Tracing: Link multiple TraceIds together into a single trace

Is there any way to join multiple traces with different trace ids into a single trace? In my case I have something like the following which I would like to join together into a single trace.

|--- UI Trace ---------------------------------|
    |- UI Span -|
                 |-- Backend Trace -----------|
                   |- Backend Span --| |--| 

Yes, I could refactor so that my Backend Trace is span within the UI Trace. But I'm working with some existing code where the the backend services already have an ID per request passed around via http headers. I would like to re-use the existing Backend ID instead of adding a new trace ID header to all existing requests.

Upvotes: 2

Views: 1946

Answers (1)

Austin Parker
Austin Parker

Reputation: 373

In general, 'joining traces' in the way you're describing would be part of your trace analyzer (Jaeger, LightStep, etc.) and I don't believe any of them allow for this sort of query. TraceID is simply a way for the analyzer to associate disparate spans into a single, logical trace.

Some options to address this would be the following -

  1. Generate a trace id of the proper format on the frontend and use that as the OpenTracing SpanContext trace id, assuming your backend will propagate this as well if it's given to it.
  2. Create a proxy that temporarily stores the spans from your UI, waits for a backend trace id to be available, and then rewrites the SpanContext with the trace id generated by the backend. You don't necessarily have to pass unfinished or malformed spans down - you could simply send the required pieces of data down the wire to your backend and create new spans for the UI at that point.

Upvotes: 2

Related Questions