mod_log_slow_events: Add metric to monitor number of slow events

Wed, 31 Aug 2016 11:29:26 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 31 Aug 2016 11:29:26 +0100
changeset 2296
8c0bf3151e37
parent 2295
2d90a2b8482e
child 2297
992e40dab31d

mod_log_slow_events: Add metric to monitor number of slow events

mod_log_slow_events/mod_log_slow_events.lua file | annotate | diff | comparison | revisions
--- 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;

mercurial