BatchingMetricProcessor implements MetricProcessor
FinalYes
Batches metrics for efficient export.
Collects metrics in memory and exports them in batches when:
- The batch size limit is reached
- flush() is explicitly called
- the system is shutting down
Example usage:
$processor = new BatchingMetricProcessor(
exporter: $metricExporter,
batchSize: 100,
);
Interfaces
- MetricProcessor
- Interface for processing metric measurements.
Methods
- __construct() : mixed
- exporter() : MetricExporter
- Get the exporter used by this processor.
- flush() : bool
- Export all pending metrics.
- process() : void
- Process a metric measurement.
Methods
__construct()
public
__construct(MetricExporter $exporter[, int $batchSize = 512 ]) : mixed
Parameters
- $exporter : MetricExporter
- $batchSize : int = 512
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