chronex v0.1.0 Chronex

Chronex

A small library to seamlessly add instrumentation to your Elixir code.

Quick Start

Chronex implements a dead simple API consisting of only one function, bind/3.

bind/3 is used to attach a stopwatch to the given function. Calling this function several times does not attach multiple stopwatches to the same function.

Note that the changes are not persisted. Thus, any attached stopwatches will be detached should their target modules be reloaded.

str = "Hello, world!"
String.length(str)
# => 13

# Attach a stopwatch to String.length/1
:ok  = Chronex.bind(String, :length, 1)

String.length(str)
# STDOUT: 15:53:09.917 [debug] chronex | 'Elixir.String':length/1 returned in 0.006 ms
# => 13

# Detach the stopwatch from String.length/1 by means of a code reload
l(String)

String.length(str)
# => 13

Configuration

Chronex will use a :debug log level by default. You can change the log level used by Chronex by simply setting Chronex’s log_level to the desired value.

config :chronex, log_level: :info

Link to this section Summary

Functions

Attach a stopwatch to the given function. The stopwatch is started on every function call targetting the given function. It measures how long it takes for the given function to run. All measurements are handled by the Logger application

Link to this section Functions

Link to this function bind(m, f0, a)
bind(atom(), atom(), non_neg_integer()) :: :ok

Attach a stopwatch to the given function. The stopwatch is started on every function call targetting the given function. It measures how long it takes for the given function to run. All measurements are handled by the Logger application.