Software /
code /
prosody-modules
Diff
mod_log_slow_events/mod_log_slow_events.lua @ 2296:8c0bf3151e37
mod_log_slow_events: Add metric to monitor number of slow events
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 31 Aug 2016 11:29:26 +0100 |
parent | 1696:efc1d674eac0 |
child | 2849:5e74028557dc |
line wrap: on
line diff
--- 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;