OpenTelemetry context propagation
Context propagation is a core concept behind OpenTelemetry’s architecture.
According to the official OpenTelemetry Glossary, context propagation enables all data sources to share an underlying context mechanism for storing state and accessing data across the lifespan of a transaction.
The context refers to metadata that is collected, stored, and carried across API boundaries by components within a distributed system. This includes information such as IDs, technology versions, and request methods.
The context is immutable: any write operation will result in creating a new context containing the original values as well as the updated values.
Propagation is the process of sending the contents of the context as metadata via a network request. Whenever your service calls another, the information that was collected in one service needs to be passed on to the other.
- Information is injected into the request on the client's side (for example, into HTTP headers) and then extracted from the headers on the server side.
- On the server side, they are de-serialized, and a new context object is created containing the original values as well as the new and updated ones.
The headers are standardized under the W3C standards for trace context to provide vendor-agnostic data.
Context propagation allows your distributed traces to be connected to their parent/child spans and follow the flow of execution; without context propagation, you would find several orphaned spans in your traces.