Skip to content

Instantly share code, notes, and snippets.

@LucaFilipozzi
Last active July 13, 2021 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucaFilipozzi/227e8e54cd4de561059e511a5947d57d to your computer and use it in GitHub Desktop.
Save LucaFilipozzi/227e8e54cd4de561059e511a5947d57d to your computer and use it in GitHub Desktop.
tracing

tracing

The W3C Trace-Context Specification defines two headers, traceparent and tracestate, that provide the ability to trace an interaction across an application stack.

traceparent

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 only 00 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 only 01 is valid

Example header: traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01

tracestate

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment