As Microservices Architecture (MSA) becomes widespread, the importance of ‘Distributed Tracing’ β tracking the flow of requests across multiple services β is growing daily. To ensure that services built with different systems and languages can smoothly exchange tracing information, a common standard is needed, and that’s exactly what W3C Trace Context provides!
Today, we’ll delve into the core headers of this standard: traceparent and tracestate.

π The Core of Standard Tracing: traceparent Header
The traceparent header can be thought of as a container for the most basic and essential information in distributed tracing. It’s like the ‘basic shipping label’ attached to a delivery box. This label contains core information, in a standardized format, necessary for identifying and linking requests.
The traceparent header consists of the following four main pieces of information:
- Version: Indicates the version of the Trace Context currently in use.
- Trace ID: A unique identifier that spans the entire request journey. βοΈ Thanks to this ID, logs and data scattered across multiple services can be grouped into a single transaction.
- Parent ID: The ID of the immediately preceding request (parent request) that directly generated this request. This information helps identify parent-child relationships between requests and visualize the service call order.
- Trace Flags: A bit field that determines whether this trace information should be sampled (recorded).
Thus, traceparent plays a crucial role in transmitting standard information that all systems must commonly understand and use.
π·οΈ The Helper for Additional Information: tracestate Header
So, why is the tracestate header needed? Because traceparent alone isn’t always enough. There might be cases where multiple company monitoring solutions (e.g., Datadog, New Relic, etc.) are used together, or special tracing information is needed for internal use only.
This is where the tracestate header shines! β¨ tracestate is a secondary header designed to carry vendor-specific unique information. It’s like attaching additional information stickers (π·οΈ) from each company to the basic shipping label (traceparent).
Key features of tracestate:
- Mutual information protection: Multiple vendors add their information as key=value pairs to a list. This prevents company A’s information from overwriting company B’s information, allowing everyone to safely transmit their data. π€
- Extensibility: It provides excellent extensibility by allowing systems to freely propagate additional context as needed without modifying the standard (traceparent).
- Information priority: The information at the very beginning of the tracestate list is considered the most recently added and thus has higher priority.
π¦ An Analogy at a Glance: Parcel Delivery Process
To aid understanding, let’s use a parcel delivery process analogy:
- traceparent: The main tracking number and address used commonly at all delivery stages. (Standard information about where it came from and where it’s going)
- tracestate:
- Logistics Center A: “Fragile sticker attached” (company_a=fragile)
- Delivery Company B: “Morning delivery preferred sticker attached” (company_b=morning_delivery)
- Warehouse C: “Storage history in zone 3 sticker attached” (company_c=zone3)
Imagine the main shipping label (traceparent) information remaining intact, while additional information stickers (tracestate) are continuously added at each stage. This makes it easy to understand.
Conclusion π
In summary, traceparent serves to transmit standardized core tracing information of the W3C Trace Context, while tracestate plays a supplementary role by helping multiple vendors transmit their unique tracing information together without conflicts.
Through the organic cooperation of these two headers, we can accurately grasp the system’s status, not losing track of the request flow even in complex microservice environments, and flexibly utilizing various monitoring tools.
Leave a Reply