Created
June 3, 2016 16:08
-
-
Save tokafish/75f1a5dabdad81253a642bdaf2ad4a75 to your computer and use it in GitHub Desktop.
Pass instrumented result to stop
This file contains hidden or 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
for {event, instrumenters} <- app_instrumenters do | |
start_callbacks = Phoenix.Endpoint.Instrument.compile_start_callbacks(event, instrumenters) | |
stop_callbacks = Phoenix.Endpoint.Instrument.compile_stop_callbacks(event, instrumenters) | |
def instrument(unquote(event), var!(compile), var!(runtime), fun) | |
when is_map(var!(compile)) and is_map(var!(runtime)) and is_function(fun, 0) do | |
unquote(start_callbacks) | |
start = :erlang.monotonic_time | |
try do | |
fun.() | |
rescue | |
error -> | |
var!(instrumented_result) = error | |
var!(diff) = :erlang.monotonic_time - start | |
unquote(stop_callbacks) | |
raise error | |
else | |
var!(instrumented_result) -> | |
var!(diff) = :erlang.monotonic_time - start | |
unquote(stop_callbacks) | |
var!(instrumented_result) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment