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']);
Tags
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
, droppedAttributeCount: int} - Normalize the SpanLink to an array representation for serialization.
Properties
$attributes
public
Attributes
$attributes
= new Attributes()
$context
public
SpanContext
$context
$droppedAttributeCount
public
int
$droppedAttributeCount
= 0
Methods
__construct()
public
__construct(SpanContext $context[, Attributes $attributes = new Attributes() ][, int $droppedAttributeCount = 0 ]) : mixed
Parameters
- $context : SpanContext
- $attributes : Attributes = new Attributes()
- $droppedAttributeCount : int = 0
create()
Create a SpanLink with the given context and optional attributes.
public
static create(SpanContext $context[, Attributes|TAttributeValueMap $attributes = [] ][, int $droppedAttributeCount = 0 ]) : self
Parameters
- $context : SpanContext
-
The linked span's context
- $attributes : Attributes|TAttributeValueMap = []
-
Link attributes
- $droppedAttributeCount : int = 0
-
Number of attributes dropped due to limits
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, droppedAttributeCount?: int} $data) : self
Parameters
-
$data
: array{context: array{traceId: array{hex: string}, spanId: array{hex: string}, parentSpanId: null|array{hex: string}, isRemote: bool}, attributes: array
, droppedAttributeCount?: int} -
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, droppedAttributeCount: int}