Skip to content

Psr7HeaderGetter

Reads W3C traceparent/tracestate (or any other propagated header) off a PSR-7 message for TraceContextPropagator::extract().

The SDK’s default ArrayAccessGetterSetter expects array-like access, which a PSR-7 message isn’t — this bridges the two.

final class Psr7HeaderGetter implements PropagationGetterInterface

ImplementsPropagationGetterInterface
SourcePsr7HeaderGetter.php
MethodDescription
get(mixed $carrier, string $key): ?stringThe comma-joined value of header $key, matched case-insensitively.
keys(mixed $carrier): arrayThe header names present on the carrier, in the message’s own casing.

public function get(mixed $carrier, string $key): ?string

The comma-joined value of header $key, matched case-insensitively.

Null when $carrier is not a PSR-7 message or the header is absent or empty, which the propagator treats as “nothing to extract”.

ParameterTypeDescription
$carriermixed
$keystring

Returns ?``string

public function keys(mixed $carrier): array

The header names present on the carrier, in the message’s own casing.

An empty array when $carrier is not a PSR-7 message, since the propagator hands over whatever it was given untyped.

ParameterTypeDescription
$carriermixed

Returns array