MetricProcessor
Interface for processing metric measurements.
Implementations may collect metrics for batching, export them immediately, or perform other processing like filtering or aggregation.
Example implementation:
final class BatchingMetricProcessor implements MetricProcessor
{
private array $buffer = [];
public function process(Metric $metric): void
{
$this->buffer[] = $metric;
if (count($this->buffer) >= 100) {
$this->flush();
}
}
}
Methods
- exporter() : MetricExporter
- Get the exporter used by this processor.
- flush() : bool
- Export all pending metrics.
- process() : void
- Process a metric measurement.
Methods
exporter()
Get the exporter used by this processor.
public
exporter() : MetricExporter
Return values
MetricExporterflush()
Export all pending metrics.
public
flush() : bool
Forces immediate export of any buffered metrics.
Return values
bool —True if all metrics were successfully exported
process()
Process a metric measurement.
public
process(Metric $metric) : void
This is invoked when an instrument records a value. The processor may buffer the metric, export it immediately, or discard it based on filtering rules.
Parameters
- $metric : Metric