instrument_counter (instrument v1.0.0)

View Source

Counter metric implementation with monotonically increasing semantics.

A counter is a cumulative metric that can only increase. It is typically used to count requests served, tasks completed, or errors occurred.

Counters use NIF-based atomic operations for high-performance concurrent updates without locks.

Example

  Counter = instrument_counter:new_counter(requests, <<"Total requests">>),
  instrument_counter:inc_counter(Counter),      % Increment by 1
  instrument_counter:inc_counter(Counter, 10),  % Increment by 10
  Value = instrument_counter:get_counter(Counter).

See also: instrument.

Summary

Functions

collect(Info, _)

get_counter(Metric)

inc_counter(Metric)

inc_counter(Metric, Val)

new_counter(Name, Help)

with_counter(Counter, F)

with_counter(Counter, F, V)