Skip to content

Instantly share code, notes, and snippets.

@amalbuquerque
Last active October 8, 2018 10:49
Show Gist options
  • Save amalbuquerque/a088bcdf17199f1d42c69c3d866e366a to your computer and use it in GitHub Desktop.
Save amalbuquerque/a088bcdf17199f1d42c69c3d866e366a to your computer and use it in GitHub Desktop.
defmodule Instrumentation do
alias My.Statix
def success_callback({module, function, args} = mfa, result, start_timestamp),
do: send_metric(mfa, "success", start_timestamp)
def error_callback({module, function, args}, error, start_timestamp),
do: send_metric(mfa, "error", start_timestamp)
defp send_metric(mfa, suffix, start_timestamp) do
now = :os.system_time(:microsecond)
time_it_took_millisecs = (now - start_timestamp)/1000
metric_name(mfa, suffix)
|> Statix.measure(time_it_took_millisecs)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment