Module otter_lib_snapshot_count

This module implements a simple way of giving operational visibility of events in the system.

Description

This module implements a simple way of giving operational visibility of events in the system. It expects a Key and Data where the Key is used to increment a counter in a table and also to store the last received Data for that Key. The Data is preferred to be a list of {K,V} tuples, if it is any other format, it uses [{data, Data}] to store the last information.

The ETS tables holding the counters/snapshots must be initialized before the feature can be used. The application using this module should call otter_lib_snapshot_count:sup_init() from a persistent process. The simplest is to call from the application supervisor init. The call only creaes the ETS tables that need an owner process to stay around.

Function Index

delete_all_counters/0Delete all counters and data (snapshot).
delete_counter/1Delete the counter and data (snapshot) for a key.
get_snap/1Return the last stored data (snapshot) for a key.
list_counts/0List all the counters with their values.
snapshot/2Increase a counter for the given Key and store the Data.
sup_init/0Initialize the ETS tables to store counters/snapshots.

Function Details

delete_all_counters/0

delete_all_counters() -> ok

Delete all counters and data (snapshot)

delete_counter/1

delete_counter(Key::term()) -> ok

Delete the counter and data (snapshot) for a key

get_snap/1

get_snap(Key::term()) -> term()

Return the last stored data (snapshot) for a key

list_counts/0

list_counts() -> [{Key::term(), Counter::integer()}]

List all the counters with their values

snapshot/2

snapshot(Key::term(), Data::term()) -> integer()

Increase a counter for the given Key and store the Data. If the data is a property (key-value) list then it adds the timestamp in {Year, Month, Day, Hour, Min, Sec, Us} format to the list with key snap_timestamp`. If it is not a property list then it stores the data in a property list with key `data and adds the timestamp. It returns the current counter value for the key.

sup_init/0

sup_init() -> term()

Initialize the ETS tables to store counters/snapshots. Should be called from a persistent process/


Generated by EDoc, May 26 2017, 14:22:06.