Flow PHP

MeterProvider

Read onlyYes
FinalYes

Entry point for the metrics API.

Creates and manages meters for different instrumentation scopes. The behavior (void, memory, OTLP, etc.) is determined by the injected processor.

Example usage:

// For testing with memory storage
$processor = new MemoryProcessor($exporter, $exporter, $exporter);
$provider = new MeterProvider($processor, new SystemClock());

// For OTLP export
$processor = batching_metric_processor(otlp_metric_exporter($transport));
$provider = new MeterProvider($processor, new SystemClock());

// For void/disabled metrics
$provider = new MeterProvider(new VoidProcessor(), new SystemClock());

$meter = $provider->meter('my-service', '1.0.0');
$counter = $meter->createCounter('requests.total');
$counter->add(1);

Methods

__construct()  : mixed
meter()  : Meter
Create a meter for the given instrumentation scope.

Methods

__construct()

public __construct(MetricProcessor $processor[, ClockInterface $clock = new SystemClock() ][, AggregationTemporality $temporality = AggregationTemporality::CUMULATIVE ][, ExemplarFilter $exemplarFilter = new TraceBasedExemplarFilter() ]) : mixed
Parameters
$processor : MetricProcessor
$clock : ClockInterface = new SystemClock()
$temporality : AggregationTemporality = AggregationTemporality::CUMULATIVE
$exemplarFilter : ExemplarFilter = new TraceBasedExemplarFilter()

meter()

Create a meter for the given instrumentation scope.

public meter(resource $resource, string $name[, string $version = 'unknown' ][, null|string $schemaUrl = null ][, null|Attributes $attributes = null ]) : Meter

Note: Instance caching is handled by the Telemetry class. This method always creates a new Meter instance.

Parameters
$resource : resource

The resource context for all metrics from this meter

$name : string

The name of the instrumentation scope (e.g., library name)

$version : string = 'unknown'

The version of the instrumentation scope

$schemaUrl : null|string = null

Schema URL for semantic conventions

$attributes : null|Attributes = null

Additional scope attributes

Return values
Meter

        
On this page

Search results