Skip to content

Instantly share code, notes, and snippets.

@Ke-
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save Ke-/13a4ac6efbd3c3bc1d61 to your computer and use it in GitHub Desktop.

Select an option

Save Ke-/13a4ac6efbd3c3bc1d61 to your computer and use it in GitHub Desktop.
Log slow requests
define sys_slow_value => 1000.0
define sys_slow_output(p=null) => {
local(s) = micros
define_atend({
local(t) = (micros - #s) / 1000.0
#t > sys_slow_value && web_request ? log_critical('SLOW: ' + client_url + ' — ' + #t + ' milliseconds')
})
}
(with i in atbegin->asstaticarray where #i->isa(::pair) select #i->second)->asstaticarray !>> 'sys_slow_output'
? define_atbegin(\sys_slow_output = 'sys_slow_output')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment