CompositePropagator implements Propagator
Read onlyYes
FinalYes
Combines multiple Propagators into a single propagator.
CompositePropagator allows using multiple propagation formats simultaneously. On inject, all propagators are invoked. On extract, all propagators are invoked and their contexts are merged.
Example usage:
$propagator = new CompositePropagator([
new W3CTraceContext(),
new W3CBaggage(),
]);
// Will inject both trace context and baggage headers
$carrier = new ArrayCarrier();
$propagator->inject($ctx, $carrier);
$headers = $carrier->toArray();
// Will extract both SpanContext and Baggage into PropagationContext
$carrier = new ArrayCarrier($headers);
$ctx = $propagator->extract($carrier);
$spanContext = $ctx->spanContext;
$baggage = $ctx->baggage;
Interfaces
- Propagator
- Interface for propagating context across process boundaries.
Methods
- __construct() : mixed
- 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
__construct()
public
__construct(array<string|int, Propagator> $propagators) : mixed
Parameters
- $propagators : array<string|int, Propagator>
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>
Return values
array<string|int, string>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