SpanLink
Read onlyYes
FinalYes
A link from one span to another.
Links are used to associate spans that are causally related but not in a direct parent-child relationship. Common use cases include:
- Batch operations where one span triggers multiple others
- Fan-in/fan-out patterns
- Linking to spans from previous traces
Example usage:
$link = SpanLink::create($otherSpanContext, ['reason' => 'batch']);
Properties
Methods
- __construct() : mixed
- create() : self
- Create a SpanLink with the given context and optional attributes.
- fromArray() : self
- Create a SpanLink from a normalized array representation.
-
normalize()
: array{context: array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool}, attributes: array
} - Normalize the SpanLink to an array representation for serialization.
Properties
$attributes
public
Attributes
$attributes
= new Attributes()
$context
public
SpanContext
$context
Methods
__construct()
public
__construct(SpanContext $context[, Attributes $attributes = new Attributes() ]) : mixed
Parameters
- $context : SpanContext
- $attributes : Attributes = new Attributes()
create()
Create a SpanLink with the given context and optional attributes.
public
static create(SpanContext $context[, array<string, array<string|int, bool|DateTimeInterface|float|int|string|Throwable>|bool|DateTimeInterface|float|int|string|Throwable> $attributes = [] ]) : self
Parameters
- $context : SpanContext
-
The linked span's context
- $attributes : array<string, array<string|int, bool|DateTimeInterface|float|int|string|Throwable>|bool|DateTimeInterface|float|int|string|Throwable> = []
-
Link attributes
Return values
selffromArray()
Create a SpanLink from a normalized array representation.
public
static fromArray(array{context: array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool}, attributes: array} $data) : self
Parameters
-
$data
: array{context: array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool}, attributes: array
} -
Normalized SpanLink data
Return values
selfnormalize()
Normalize the SpanLink to an array representation for serialization.
public
normalize() : array{context: array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool}, attributes: array}