Skip to content

Instantly share code, notes, and snippets.

@amalbuquerque
Last active October 8, 2018 10:49
Show Gist options
  • Save amalbuquerque/c957afbe4bd97777ef5e183ab460978d to your computer and use it in GitHub Desktop.
Save amalbuquerque/c957afbe4bd97777ef5e183ab460978d to your computer and use it in GitHub Desktop.
defmodule Foo do
def bar(x, y) do
start_time = :os.system_time(:microsecond)
try do
success_result = x / y
Kernel.apply(Instrumentation,:success_callback,
[
{Foo, :bar, [x, y]},
success_result,
start_time
])
success_result
rescue
error ->
Kernel.apply(Instrumentation,:error_callback,
[
{Foo, :bar, [x, y]},
error,
start_time
])
reraise(error, __STACKTRACE__)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment