SpanId implements Stringable
Read onlyYes
FinalYes
An 8-byte (64-bit) span identifier compatible with OpenTelemetry W3C Trace Context.
SpanIds uniquely identify a span within a trace. All-zero SpanIds are rejected at construction time per W3C spec.
Example usage:
$spanId = SpanId::generate();
echo $spanId->toHex(); // "00f067aa0ba902b7"
Interfaces
- Stringable
Methods
- __toString() : string
- equals() : bool
- Check if this SpanId equals another SpanId.
- fromArray() : self
- Create a SpanId from a normalized array representation.
- fromBytes() : self
- Create a SpanId from 8 raw bytes.
- fromHex() : self
- Create a SpanId from a 16-character hexadecimal string.
- generate() : self
- Generate a new random SpanId.
- normalize() : array{hex: string}
- Normalize the SpanId to an array representation for serialization.
- toBytes() : string
- Get the SpanId as 8 raw bytes.
- toHex() : string
- Get the SpanId as a 16-character lowercase hexadecimal string.
Methods
__toString()
public
__toString() : string
Return values
stringequals()
Check if this SpanId equals another SpanId.
public
equals(self $other) : bool
Parameters
- $other : self
Return values
boolfromArray()
Create a SpanId from a normalized array representation.
public
static fromArray(array{hex: string} $data) : self
Parameters
- $data : array{hex: string}
-
Normalized SpanId data
Tags
Return values
selffromBytes()
Create a SpanId from 8 raw bytes.
public
static fromBytes(string $bytes) : self
Parameters
- $bytes : string
-
8 raw bytes
Tags
Return values
selffromHex()
Create a SpanId from a 16-character hexadecimal string.
public
static fromHex(string $hex) : self
Parameters
- $hex : string
-
16-character lowercase hexadecimal string
Tags
Return values
selfgenerate()
Generate a new random SpanId.
public
static generate() : self
Return values
selfnormalize()
Normalize the SpanId to an array representation for serialization.
public
normalize() : array{hex: string}
Return values
array{hex: string}toBytes()
Get the SpanId as 8 raw bytes.
public
toBytes() : string
Return values
stringtoHex()
Get the SpanId as a 16-character lowercase hexadecimal string.
public
toHex() : string