macula_diagnostics_bound (macula v11.5.0)

View Source

The bound behind macula_diagnostics:bounded_event/3: a diagnostics event goes to the log at most once per window, 10 seconds, per event name, node-wide.

The first event of a name is logged and opens its window. An event inside the window is counted and becomes the latest, and is not logged. The first event after the window takes the next one and is logged with suppressed, the number held back since the line before. Once per window this process logs the count a burst left inside a window that no later event has closed, with the latest properties, and that opens the next window.

Callers update the counts table themselves with atomic ETS updates, so a burst never queues on this process: it owns the table and handles only its own sweep. Without the table, between an owner's exit and its restart, an event is logged as it is.

Summary

Functions

Log an event through the counts table Table, at most once per window for its name.

Run the sweep now, at the table's clock.

Types

options/0

-type options() ::
          #{table => atom(),
            clock => fun(() -> integer()),
            window_ms => pos_integer(),
            sweep => periodic | manual}.

Functions

event(Table, Level, Topic, Properties)

-spec event(atom(), macula_diagnostics:level(), binary(), map()) -> ok.

Log an event through the counts table Table, at most once per window for its name.

handle_call(Request, From, State)

handle_cast(Message, State)

handle_info(Message, State)

init(Options)

start_link()

-spec start_link() -> {ok, pid()} | {error, term()}.

start_link(Options)

-spec start_link(options()) -> {ok, pid()} | {error, term()}.

sweep(Owner)

-spec sweep(pid()) -> ok.

Run the sweep now, at the table's clock.