Flow PHP

Context

FinalYes

Telemetry context carrier holding the active span and baggage.

Follows the OpenTelemetry context model: a Context either carries the currently active span (its SpanContext) — making the next span its child within the same trace — or carries none, making the next span a new trace root. Trace id is always derived from the active span; it is never stored independently.

Example usage:

$context = Context::root();
$context = $context->withActiveSpan($span->context());
echo $context->traceId()?->toHex();

Properties

$activeSpan  : SpanContext|null
$baggage  : Baggage

Methods

__construct()  : mixed
activeSpan()  : SpanContext|null
activeSpanId()  : SpanId|null
fromArray()  : self
isRootContext()  : bool
normalize()  : array{activeSpan: null|array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool, traceFlags: array{byte: int}, traceState: array{entries: array}}, baggage: array{entries: array}}
root()  : self
traceId()  : TraceId|null
withActiveSpan()  : self
withBaggage()  : self
withoutActiveSpan()  : self

Properties

Methods

fromArray()

public static fromArray(array{activeSpan: null|array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool, traceFlags?: array{byte: int}, traceState?: array{entries: array}}, baggage: array{entries: array}} $data) : self
Parameters
$data : array{activeSpan: null|array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool, traceFlags?: array{byte: int}, traceState?: array{entries: array}}, baggage: array{entries: array}}
Return values
self

isRootContext()

public isRootContext() : bool
Return values
bool

normalize()

public normalize() : array{activeSpan: null|array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool, traceFlags: array{byte: int}, traceState: array{entries: array}}, baggage: array{entries: array}}
Return values
array{activeSpan: null|array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool, traceFlags: array{byte: int}, traceState: array{entries: array}}, baggage: array{entries: array}}

root()

public static root() : self
Return values
self

withBaggage()

public withBaggage(Baggage $baggage) : self
Parameters
$baggage : Baggage
Return values
self

withoutActiveSpan()

public withoutActiveSpan() : self
Return values
self
On this page

Search results