TelemetryDecorator

Build status badgeHex version badge

A function decorator for telemetry.

Usage

defmodule MyApp.MyModule do
use TelemetryDecorator
@decorate telemetry([:my_app, :succeed])
def succeed(arg1, arg2) do
:...
end
end

Because we're using :telemetry.span/3 under the hood, you'll get these events:

Because we're wrapping it with Decorator, we can provide more metadata than :telemetry.span/3 usually does:

To include more internal variables in your :stop events, add the include option:

defmodule MyApp.MyModule do
use TelemetryDecorator
def succeed(why), do: succeed(why, [])
@decorate telemetry([:my_app, :succeed], include: [:type])
def succeed(why, opts) do
type = Keyword.get(opts, :type, :ok)
{type, why}
end
end

To watch :telemetry.span/3 style events at the iex> prompt:

handler_id = TelemetryDecorator.watch([:my_app, :succeed])
MyApp.MyModule.succeed(42)
# hang up, or explicitly unwatch:
TelemetryDecorator.unwatch(handler_id)

TelemetryDecorator.watch/1 sends to remote consoles, too, and with syntax colours. See the documentation for Pretty to find out how.

Installation

Add telemetry_decorator to your list of dependencies in mix.exs:

def deps do
[
{:telemetry_decorator, "~> 1.0.0"}
]
end

Development

make check before you commit! If you'd prefer to do it manually: