Instrument
Base interface for metric instruments.
Instruments are responsible for recording measurements and aggregating them internally. Each instrument type has different aggregation semantics:
- Counter: Sum aggregation (monotonically increasing)
- UpDownCounter: Sum aggregation (bidirectional)
- Gauge: Last value aggregation
- Histogram: Distribution aggregation (count, sum, min, max)
Tags
Methods
- 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
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|nullname()
Get the instrument name.
public
name() : string
Return values
stringunit()
Get the unit of measurement.
public
unit() : string|null