-
-
Save amalbuquerque/a088bcdf17199f1d42c69c3d866e366a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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