diff plugins/mod_csi_simple.lua @ 13991:0ff11f2e87cd

mod_csi_simple: Collect stats on why stanzas are held To mirror flush reasons.
author Kim Alvefur <zash@zash.se>
date Fri, 07 Nov 2025 00:29:44 +0100
parents 598359d9f580
children
line wrap: on
line diff
--- a/plugins/mod_csi_simple.lua	Wed Nov 05 16:19:50 2025 +0100
+++ b/plugins/mod_csi_simple.lua	Fri Nov 07 00:29:44 2025 +0100
@@ -122,6 +122,12 @@
 	{ "reason" }
 );
 
+local hold_reasons = module:metric(
+	"counter", "hold", "",
+	"CSI queue held",
+	{ "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();
 
@@ -144,6 +150,7 @@
 		module:fire_event("csi-flushing", { session = session });
 		session.conn:resume_writes();
 	else
+		hold_reasons:with_labels(why or "unimportant"):add(1);
 		session.log("debug", "Holding buffer (%s; queue size is %d)", why or "unimportant", session.csi_counter);
 		stanza = with_timestamp(stanza, jid.join(session.username, session.host))
 	end