Flow PHP

Throughput implements Instrument

FinalYes

Throughput instrument for tracking rate of items processed over time.

Throughput tracks accumulated count and calculates rate (count/time unit). Unlike Gauge which replaces values, Throughput accumulates via add() calls. The timer starts from the first add() call for each attribute combination.

Example usage:

$throughput = $meter->createThroughput('dataframe_throughput', 'rows', 'Rows processed per second');
$throughput->add(100, ['source' => 'csv']); // Process 100 rows
$throughput->add(150, ['source' => 'csv']); // Process 150 more rows
$metrics = $throughput->collect(); // Returns rate as value (rows/s)

Interfaces

Instrument
Base interface for metric instruments.

Methods

__construct()  : mixed
add()  : void
Add to the accumulated count.
collect()  : array<string|int, Metric>
Collect aggregated metrics for export.
description()  : string|null
Get the instrument description.
name()  : string
Get the instrument name.
unit()  : string|null
Get the unit of measurement.

Methods

__construct()

public __construct(string $name, resource $resource, InstrumentationScope $scope, ClockInterface $clock[, AggregationTemporality $temporality = AggregationTemporality::CUMULATIVE ][, ExemplarFilter $exemplarFilter = new TraceBasedExemplarFilter() ][, null|string $unit = null ][, null|string $description = null ][, null|int $ratePrecision = 2 ][, TimeUnit $timeUnit = TimeUnit::SECONDS ]) : mixed
Parameters
$name : string

Instrument name

$resource : resource

The resource context for this instrument

$scope : InstrumentationScope

Instrumentation scope that created this instrument

$clock : ClockInterface

Clock for timestamps

$temporality : AggregationTemporality = AggregationTemporality::CUMULATIVE

Aggregation temporality

$exemplarFilter : ExemplarFilter = new TraceBasedExemplarFilter()

Filter for exemplar sampling

$unit : null|string = null

Unit of measurement (e.g., 'rows', 'bytes')

$description : null|string = null

Human-readable description

$ratePrecision : null|int = 2

Number of decimal places for rate calculation (default: 2, null for no rounding)

$timeUnit : TimeUnit = TimeUnit::SECONDS

Time unit for rate calculation (default: SECONDS)

add()

Add to the accumulated count.

public add(int $count[, array<string, array<string|int, bool|float|int|string>|bool|float|int|string>|Attributes $attributes = [] ][, null|SpanContext $context = null ]) : void
Parameters
$count : int

Number of items to add

$attributes : array<string, array<string|int, bool|float|int|string>|bool|float|int|string>|Attributes = []

Categorization attributes

$context : null|SpanContext = null

Optional span context for exemplar capture

collect()

Collect aggregated metrics for export.

public collect() : array<string|int, Metric>

Returns all aggregated metrics since the last collection, then resets the internal aggregation state.

Return values
array<string|int, Metric>

Aggregated metrics ready for export

description()

Get the instrument description.

public description() : string|null
Return values
string|null

name()

Get the instrument name.

public name() : string
Return values
string

unit()

Get the unit of measurement.

public unit() : string|null
Return values
string|null

        
On this page

Search results