metrex v0.0.2 Metrex.Counter

Counter metrics implementation

Examples

Static counters

Add list of counters into config.exs file to autostart counters:

config :metrex,
  counters: ["pageviews"]

On-demand counters

To create on-demand counters, you need to call start_link function:

# Initialize counter with 0
Metrex.Counter.start_link("special_clicks")

# Initialize counter with x(number)
Metrex.Counter.start_link("special_clicks", 28)

Counter operations

Counter operations are increment, decrement and count:

# Increment a counter by 1
Metrex.Counter.increment("pageviews")

# Increment a counter by x(number)
Metrex.Counter.increment("pageviews", 5)

# Decrement a counter by 1
Metrex.Counter.decrement("pageviews")

# Decrement a counter by x(number)
Metrex.Counter.decrement("pageviews", 3)

# Get current counter
Metrex.Counter.count("pageviews")

Summary

Functions

Display current counter

Decrement metric by given val

Increment metric by given val

Start a new counter metric

Functions

count(metric)

Display current counter

decrement(metric, val \\ 1)

Decrement metric by given val

increment(metric, val \\ 1)

Increment metric by given val

start_link(metric, val \\ 0)

Start a new counter metric