Flow PHP

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

Example usage:

$processor = new CompositeMetricProcessor([
    new BatchingMetricProcessor($otlpExporter),
    new MemoryMetricProcessor(),
]);

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.
processors()  : array<string|int, MetricProcessor>
Get all processors in this composite.

Methods

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

        
On this page

Search results