aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-06-14 03:31:30 +0200
committerKim Alvefur <zash@zash.se>2022-06-14 03:31:30 +0200
commit07660a908817500a6f17dd2fad8cc38f373d82f1 (patch)
treec872d6aa1cedb8f25afbe7100a65c19d64a9a02f
parentd0ab468f40151e5e728ed9590313cea1820b8ff7 (diff)
downloadprosody-07660a908817500a6f17dd2fad8cc38f373d82f1.tar.gz
prosody-07660a908817500a6f17dd2fad8cc38f373d82f1.zip
mod_csi_simple: Collect stats on number of stanzas per flush
Because interesting, gives some idea about the efficiency.
-rw-r--r--plugins/mod_csi_simple.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/plugins/mod_csi_simple.lua b/plugins/mod_csi_simple.lua
index 569916b0..b9a470f5 100644
--- a/plugins/mod_csi_simple.lua
+++ b/plugins/mod_csi_simple.lua
@@ -116,6 +116,9 @@ local flush_reasons = module:metric(
{ "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 @@ local function manage_buffer(stanza, session)
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 @@ local function flush_buffer(data, session)
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();