Flow PHP

Exemplar

Read onlyYes
FinalYes

Represents a sample measurement with trace context.

Exemplars provide a link between aggregated metric data and the distributed traces that contributed to that data. They capture a representative measurement along with its trace context.

Example:

$exemplar = new Exemplar(
    value: 125.5,
    timestamp: new \DateTimeImmutable(),
    traceId: $context->traceId,
    spanId: $activeSpanId,
    filteredAttributes: ['http.method' => 'GET'],
);

Properties

$filteredAttributes  : array<string|int, mixed>
$spanId  : SpanId
$timestamp  : DateTimeImmutable
$traceId  : TraceId
$value  : int|float

Methods

__construct()  : mixed
fromArray()  : self
Create an Exemplar from a normalized array representation.
normalize()  : array{value: float|int, timestamp: string, traceId: array{hex: string}, spanId: array{hex: string}, filteredAttributes: array}
Normalize the Exemplar to an array representation for serialization.

Properties

$filteredAttributes

public array<string|int, mixed> $filteredAttributes = []

$timestamp

public DateTimeImmutable $timestamp

Methods

__construct()

public __construct(float|int $value, DateTimeImmutable $timestamp, TraceId $traceId, SpanId $spanId[, array<string, bool|float|int|string> $filteredAttributes = [] ]) : mixed
Parameters
$value : float|int

The recorded measurement value

$timestamp : DateTimeImmutable

When the measurement was recorded

$traceId : TraceId

The trace ID from the active context

$spanId : SpanId

The span ID from the active context

$filteredAttributes : array<string, bool|float|int|string> = []

Subset of attributes for this exemplar

fromArray()

Create an Exemplar from a normalized array representation.

public static fromArray(array{value: float|int, timestamp: string, traceId: array{hex: string}, spanId: array{hex: string}, filteredAttributes: array$data) : self
Parameters
$data : array{value: float|int, timestamp: string, traceId: array{hex: string}, spanId: array{hex: string}, filteredAttributes: array}

Normalized Exemplar data

Return values
self

normalize()

Normalize the Exemplar to an array representation for serialization.

public normalize() : array{value: float|int, timestamp: string, traceId: array{hex: string}, spanId: array{hex: string}, filteredAttributes: array}
Return values
array{value: float|int, timestamp: string, traceId: array{hex: string}, spanId: array{hex: string}, filteredAttributes: array}

        
On this page

Search results