Flow PHP

Gauge implements Instrument

FinalYes

Gauge instrument for recording non-additive values.

Gauges record the current value at a point in time. Unlike counters, gauge values are not summed - only the last recorded value is kept.

Example usage:

$gauge = $meter->createGauge('system.memory.usage', 'bytes', 'Current memory usage');
$gauge->record(1024 * 1024 * 512, ['host' => 'server-1']);
$gauge->record(1024 * 1024 * 480, ['host' => 'server-1']); // Replaces previous
Tags
see
https://opentelemetry.io/docs/specs/otel/metrics/api/#gauge

Interfaces

Instrument
Base interface for metric instruments.

Methods

__construct()  : mixed
collect()  : array<string|int, Metric>
Collect aggregated metrics for export.
description()  : string|null
Get the instrument description.
name()  : string
Get the instrument name.
record()  : void
Record a gauge value.
unit()  : string|null
Get the unit of measurement.

Methods

__construct()

public __construct(string $name, resource $resource, InstrumentationScope $scope, ClockInterface $clock[, ExemplarFilter $exemplarFilter = new TraceBasedExemplarFilter() ][, null|string $unit = null ][, null|string $description = null ]) : 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

$exemplarFilter : ExemplarFilter = new TraceBasedExemplarFilter()

Filter for exemplar sampling

$unit : null|string = null

Unit of measurement

$description : null|string = null

Human-readable description

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

record()

Record a gauge value.

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

Current value to record

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

Categorization attributes

$context : null|SpanContext = null

Optional span context for exemplar capture

unit()

Get the unit of measurement.

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

        
On this page

Search results