OxL Справочник OxL
РусскийEnglish

data Counter

A value that only grows (requests served, errors). Name it …_total.

Example:

oxl✓ проверяется в CI
use std.obs { metric }

fn main() io {
  let c = metric.counter("requests_total", "requests served")
  c.inc()
  c.add(2)
  print("{c.value()}")
}
Вывод
3.0
pub(api) data Counter

Потокобезопасность. safe from any task; updates are atomic.

С версии. 1.0.0-beta

Методы

inc() io
Adds 1.
add(n: f64) io
Adds n (>= 0; a negative amount is ignored).
value() -> f64 io
Current value.

Определено в: std/obs/obs.oxl:518

См. также