Flow PHP

TraceState implements Stringable

Read onlyYes
FinalYes

W3C Trace Context tracestate header value.

TraceState provides vendor-specific trace identification data and enables multiple tracing systems to participate in the same trace. It's an immutable list of key-value pairs with ordering preserved.

Example usage:

$state = TraceState::empty();
$state = $state->with('vendor', 'value');
echo $state->toString(); // "vendor=value"
Tags
see
https://www.w3.org/TR/trace-context/#tracestate-header

Interfaces

Stringable

Methods

__toString()  : string
all()  : array<string, string>
Get all entries as an array.
empty()  : self
Create an empty TraceState.
equals()  : bool
Check if this TraceState equals another TraceState.
fromArray()  : self
Create TraceState from a normalized array representation.
fromString()  : self
Create TraceState from W3C tracestate header string.
get()  : null|string
Get a value by key.
isEmpty()  : bool
Check if this TraceState has any entries.
normalize()  : array{entries: array}
Normalize the TraceState to an array representation for serialization.
toString()  : string
Convert to W3C tracestate header string.
with()  : self
Create a new TraceState with a key-value pair added or updated.
without()  : self
Create a new TraceState with a key removed.

Methods

__toString()

public __toString() : string
Return values
string

all()

Get all entries as an array.

public all() : array<string, string>
Return values
array<string, string>

empty()

Create an empty TraceState.

public static empty() : self
Return values
self

equals()

Check if this TraceState equals another TraceState.

public equals(self $other) : bool
Parameters
$other : self
Return values
bool

fromArray()

Create TraceState from a normalized array representation.

public static fromArray(array{entries: array$data) : self
Parameters
$data : array{entries: array}

Normalized TraceState data

Return values
self

fromString()

Create TraceState from W3C tracestate header string.

public static fromString(string $string) : self
Parameters
$string : string

W3C tracestate header value

Tags
throws
InvalidArgumentException

if the string is malformed

Return values
self

get()

Get a value by key.

public get(string $key) : null|string
Parameters
$key : string
Return values
null|string

The value or null if not found

isEmpty()

Check if this TraceState has any entries.

public isEmpty() : bool
Return values
bool

normalize()

Normalize the TraceState to an array representation for serialization.

public normalize() : array{entries: array}
Return values
array{entries: array}

toString()

Convert to W3C tracestate header string.

public toString() : string
Return values
string

with()

Create a new TraceState with a key-value pair added or updated.

public with(string $key, string $value) : self

New entries are added at the beginning (most recent position).

Parameters
$key : string
$value : string
Tags
throws
InvalidArgumentException

if the key or value is invalid

Return values
self

without()

Create a new TraceState with a key removed.

public without(string $key) : self
Parameters
$key : string
Return values
self

        
On this page

Search results