Using an asynchronous gauge
System.Diagnostics.Metrics.ObservableGauge
represents the current value of a non-additive metric. There is only an asynchronous version of it.
The key difference with ObservableUpdownCounter
is that the counter is additive. For example, with counters, if we have multiple metric points for the same counter name, at the same timestamp, and with the same attributes, we can just add them up. For gauge, aggregation makes no sense and OpenTelemetry uses the last reported value.
When exported to Prometheus, ObservableGauge
and ObservableUpdownCounter
are the same, but their OTLP definitions (over-the-wire formats) are different.
Tip
You can get an idea of the internal representation of metric points on the OpenTelemetry side by enabling the ConsoleExporter
output or looking into the OpenTelemetry documentation at https://opentelemetry.io/docs/reference/specification/overview/#metrics-data-model-and-sdk.
We use ObservableGauge
to report a sequence...