# HG changeset patch # User Matthew Wild # Date 1472639366 -3600 # Node ID 8c0bf3151e37981bed370e2b5a8ca0a7c30c3bbc # Parent 2d90a2b8482ec181de0c430301fb2235e32febc1 mod_log_slow_events: Add metric to monitor number of slow events diff -r 2d90a2b8482e -r 8c0bf3151e37 mod_log_slow_events/mod_log_slow_events.lua --- a/mod_log_slow_events/mod_log_slow_events.lua Tue Aug 30 15:15:24 2016 +0200 +++ b/mod_log_slow_events/mod_log_slow_events.lua Wed Aug 31 11:29:26 2016 +0100 @@ -3,6 +3,8 @@ local max_seconds = module:get_option_number("log_slow_events_threshold", 0.5); +local measure_slow_event = module:measure("slow_events", "rate"); + function event_wrapper(handlers, event_name, event_data) local start = time(); local ret = handlers(event_name, event_data); @@ -44,6 +46,7 @@ end end end + measure_slow_event(); module:log("warn", "Slow event '%s' took %0.2fs: %s", event_name, duration, next(data) and table.concat(data, ", ") or "no recognised data"); end return ret;