Changeset

12552:b4bc5a715e65

mod_csi_simple: Collect stats on number of stanzas per flush Because interesting, gives some idea about the efficiency.
author Kim Alvefur <zash@zash.se>
date Tue, 14 Jun 2022 03:31:30 +0200
parents 12551:3b7e97e0a8ef
children 12554:dbbbcf6b805e
files plugins/mod_csi_simple.lua
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_csi_simple.lua	Mon Jun 13 21:25:42 2022 +0200
+++ b/plugins/mod_csi_simple.lua	Tue Jun 14 03:31:30 2022 +0200
@@ -116,6 +116,9 @@
 	{ "reason" }
 );
 
+local flush_sizes = module:metric("histogram", "flush_stanza_count", "", "Number of stanzas flushed at once", {},
+	{ buckets = { 0, 1, 2, 4, 8, 16, 32, 64, 128, 256 } }):with_labels();
+
 local function manage_buffer(stanza, session)
 	local ctr = session.csi_counter or 0;
 	if session.state ~= "inactive" then
@@ -129,6 +132,7 @@
 			session.csi_measure_buffer_hold = nil;
 		end
 		flush_reasons:with_labels(why or "important"):add(1);
+		flush_sizes:sample(ctr);
 		session.log("debug", "Flushing buffer (%s; queue size is %d)", why or "important", session.csi_counter);
 		session.state = "flushing";
 		module:fire_event("csi-flushing", { session = session });
@@ -147,6 +151,7 @@
 	session.log("debug", "Flushing buffer (%s; queue size is %d)", "client activity", session.csi_counter);
 	session.state = "flushing";
 	module:fire_event("csi-flushing", { session = session });
+	flush_sizes:sample(ctr);
 	flush_reasons:with_labels("client activity"):add(1);
 	if session.csi_measure_buffer_hold then
 		session.csi_measure_buffer_hold();