Propagator
Interface for propagating context across process boundaries.
Propagator defines how context information (like trace identifiers and baggage) is injected into and extracted from carriers such as HTTP headers, gRPC metadata, or message queue headers.
Example usage:
$propagator = new W3CTraceContext();
// Extract context from incoming request headers
$carrier = new ArrayCarrier($incomingHeaders);
$ctx = $propagator->extract($carrier);
// Inject context into outgoing request headers
$carrier = new ArrayCarrier();
$propagator->inject($ctx, $carrier);
$headers = $carrier->toArray();
Methods
- extract() : PropagationContext
- Extract context from a carrier.
- fields() : array<string|int, string>
- Get the list of header/field names this propagator uses.
- inject() : void
- Inject context into a carrier.
Methods
extract()
Extract context from a carrier.
public
extract(Carrier $carrier) : PropagationContext
Parameters
- $carrier : Carrier
-
The carrier to extract from
Return values
PropagationContext —The extracted context
fields()
Get the list of header/field names this propagator uses.
public
fields() : array<string|int, string>
This is useful for CORS configuration and carrier filtering.
Return values
array<string|int, string> —List of field names
inject()
Inject context into a carrier.
public
inject(PropagationContext $context, Carrier $carrier) : void
Parameters
- $context : PropagationContext
-
The context to inject
- $carrier : Carrier
-
The carrier to inject into