I've been reading the W3C Trace Context spec and I can't figure out how to get child-of relationships between spans from just looking at the headers in my requests.
Assuming I understand the processing model correctly, the first service generates a traceparent
, while subsequent services replace the parentId
within the traceparent
for downstream requests.
So Service A generates a traceparent
and sends a request to Service B:
host: service-b
traceparent: 00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01
Service B receives the requests and does two downstream requests to Service C and Service D each time changing the parentId
:
host: service-c
traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01
host: service-d
traceparent: 00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-01
At the end I have three traceparent
s in my requests
00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01
00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01
00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-01
It's easy to see that they all belong to the trace 0af7651916cd43dd8448eb211c80319c
, but how do I figure out the parent child relationship between them?
My initial thought was that this is done using tracestate
, but the spec states:
tracestate extends traceparent with vendor-specific data represented by a set of name/value pairs. Storing information in tracestate is optional.