ExemplarReservoir
Stores a bounded collection of exemplars for metric aggregation.
ExemplarReservoir determines how many and which exemplars to keep during the metric collection period. Different reservoir types implement different sampling strategies appropriate for their associated instrument types.
Example usage:
$reservoir = new SimpleFixedSizeExemplarReservoir(5);
$reservoir->offer(100, ['status' => 'ok'], $spanContext, $timestamp);
$exemplars = $reservoir->collect();
Methods
- collect() : array<string|int, Exemplar>
- Collect all stored exemplars.
- offer() : void
- Offer a measurement for potential storage as an exemplar.
- reset() : void
- Clear all stored exemplars.
Methods
collect()
Collect all stored exemplars.
public
collect([bool $reset = true ]) : array<string|int, Exemplar>
Parameters
- $reset : bool = true
-
Whether to clear the reservoir after collection
Return values
array<string|int, Exemplar>offer()
Offer a measurement for potential storage as an exemplar.
public
offer(float|int $value, array<string, array<string|int, bool|float|int|string>|bool|float|int|string> $attributes, SpanContext $context, DateTimeImmutable $timestamp[, int $bucketIndex = 0 ]) : void
The reservoir decides whether to keep this measurement based on its sampling strategy. Not all offered measurements will be stored.
Parameters
- $value : float|int
-
The measurement value
- $attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string>
-
The measurement attributes
- $context : SpanContext
-
The span context for trace correlation
- $timestamp : DateTimeImmutable
-
When the measurement was recorded
- $bucketIndex : int = 0
-
For histogram buckets, the bucket index; ignored by other reservoirs
reset()
Clear all stored exemplars.
public
reset() : void