ExemplarFilter extends Stringable
Determines whether an exemplar should be recorded for a metric measurement.
ExemplarFilter is used to decide when to capture trace context alongside metric data points. This enables drill-down from metrics to traces when exported to backends that support exemplars.
Example usage:
$filter = new TraceBasedExemplarFilter();
if ($filter->shouldSample($spanContext, 100, ['status' => 'ok'])) {
// Record exemplar with trace context
}
Methods
- shouldSample() : bool
- Determine whether to record an exemplar for this measurement.
Methods
shouldSample()
Determine whether to record an exemplar for this measurement.
public
shouldSample(null|SpanContext $context, float|int $value, array<string, array<string|int, bool|float|int|string>|bool|float|int|string> $attributes) : bool
Parameters
- $context : null|SpanContext
-
The current span context, or null if none
- $value : float|int
-
The measurement value
- $attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string>
-
The measurement attributes