The W3C Trace-Context Specification defines two headers, traceparent and tracestate, that provide the ability to trace an interaction across an application stack.
traceparent is used to convey trace_id and parent_id from parent to child. For example, from a WAF (F5 BigIP, say) to a Web Server (Apache httpd, say).
Its format is <version>-<trace_id>-<parent_id>-<trace_flags>
where (HEXDIGLC = lowercase hexadecmial digit [0-9a-f]):
<version>
is 2HEXDIGLC, currently only00
is valid<trace_id>
is 32HEXDIGLC, unique globally (e.g.: a UUID4, lower, hypens removed)<parent_id>
is 16HEXDIGLC, unique within trace_id<trace_flags>
is 2HEXDIGLC, currently only01
is valid
Example header: traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01
tracestate is used to convey key-value pairs from a parent system to a child system to propagate context.
A system must propagate the context it received from a parent to a child system subject to the following rules
- leave existing unmodofied key-value pairs in the order received
- append new key-value pairs to the end (right)
- modify existing keys-value pairs by assiging a new value and moving the key-value pair to the end (right)
Example header (A to B): tracestate: foo=1234,bar=5678,qux=9012
.
Example header (B to C): tracestate: foo=1234,qux=9012,bar=abcd,baz=efgh
with bar modified and baz appended.