changeset 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
parents 2d90a2b8482e
children 992e40dab31d
files mod_log_slow_events/mod_log_slow_events.lua
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
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;