GAUGE
GAUGE = 'gauge'
A value that can move in either direction.
Named numbers with their units, ready to be exported.
OTLP distinguishes a gauge from a counter and a collector treats them differently - a counter is expected to only ever rise, and one that falls is read as a process restart rather than as a real decrease. So the kind is recorded here rather than guessed at export time: stored bytes is a gauge, requests performed is a counter, and getting that backwards produces a graph that is wrong in a way nobody notices.
gauge(string $name, float $value, string $unit = '', array$attributes = []) : self
Records a gauge.
| string | $name | The metric name, such as "strata.stored_bytes". |
| float | $value | The reading. |
| string | $unit | The UCUM unit, such as "By" for bytes or "s" for seconds. |
| array |
$attributes | Dimensions, such as the realm or the provider. |
This set, for chaining.
set(string $name, float $value, string $kind, string $unit, array$attributes) : self
Records one metric.
The key is the name AND its attributes. One name carries several series when it is
dimensioned - open findings per severity, request counts per class - and keying on the name
alone would have each dimension overwrite the last, leaving one arbitrary series exported and
the rest silently gone. The stored name stays the plain metric name, so the wire shape is
unaffected.
The same name with the same attributes recorded twice keeps the later value, because the second reading is the more recent one and a set is a snapshot rather than a log.
| string | $name | The metric name. |
| float | $value | The reading. |
| string | $kind | Either GAUGE or COUNTER. |
| string | $unit | The UCUM unit. |
| array |
$attributes | Dimensions. |
This set, for chaining.
key(string $name, array$attributes) : string
The key one dimensioned reading is stored under.
Attributes are sorted so the same dimensions in a different order resolve to one series rather than two.
| string | $name | The metric name. |
| array |
$attributes | Dimensions. |
The key.