CompositeMetricProcessor implements MetricProcessor
Read onlyYes
FinalYes
Forwards metrics to multiple processors.
This is useful when you need to:
- Send metrics to multiple backends (e.g., both Prometheus and OTLP)
- Combine batching with memory storage for testing
- Add custom processing alongside export
Interfaces
- MetricProcessor
- Interface for processing metric measurements.
Methods
- __construct() : mixed
- flush() : bool
- Export all pending metrics.
- process() : void
- Process a metric measurement.
- processors() : array<string|int, MetricProcessor>
- Get all processors in this composite.
- shutdown() : void
- Shutdown the processor.
Methods
__construct()
public
__construct(array<string|int, MetricProcessor> $processors[, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : mixed
Parameters
- $processors : array<string|int, MetricProcessor>
- $errorHandler : ErrorHandler = new ErrorLogHandler()
flush()
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
processors()
Get all processors in this composite.
public
processors() : array<string|int, MetricProcessor>
Return values
array<string|int, MetricProcessor>shutdown()
Shutdown the processor.
public
shutdown() : void
Implementations SHOULD flush() pending data before delegating shutdown to the underlying exporter. MUST be idempotent and MUST NOT throw.