OxL Reference

data Counter

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

Example:

oxl✓ checked in CI
use std.obs { metric }

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

Thread safety. safe from any task; updates are atomic.

Since. 1.0.0-beta

Methods

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

Defined in: std/obs/obs.oxl:518

See also