aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJonas Schäfer <jonas@wielicki.name>2021-05-20 14:00:54 +0200
committerJonas Schäfer <jonas@wielicki.name>2021-05-20 14:00:54 +0200
commit93a2f1559d35edda4ccecc1682d3ee68645d2d50 (patch)
tree83bf7e5e97a4780d3f3d040d15fd97c2f890964f /plugins
parente549430c12c03bdb219c02ac42f4f37cda830d98 (diff)
downloadprosody-93a2f1559d35edda4ccecc1682d3ee68645d2d50.tar.gz
prosody-93a2f1559d35edda4ccecc1682d3ee68645d2d50.zip
mod_csi_simple: convert to use new metric interface for flush reasons
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_csi_simple.lua17
1 files changed, 7 insertions, 10 deletions
diff --git a/plugins/mod_csi_simple.lua b/plugins/mod_csi_simple.lua
index be63c325..38b6df29 100644
--- a/plugins/mod_csi_simple.lua
+++ b/plugins/mod_csi_simple.lua
@@ -107,14 +107,11 @@ end
local measure_buffer_hold = module:measure("buffer_hold", "times");
-local flush_reasons = setmetatable({}, {
- __index = function (t, reason)
- local m = module:measure("flush_reason."..reason:gsub("%W", "_"), "rate");
- t[reason] = m;
- return m;
- end;
- });
-
+local flush_reasons = module:metric(
+ "counter", "flushes", "",
+ "CSI queue flushes",
+ { "reason" }
+);
local function manage_buffer(stanza, session)
local ctr = session.csi_counter or 0;
@@ -124,7 +121,7 @@ local function manage_buffer(stanza, session)
session.csi_measure_buffer_hold();
session.csi_measure_buffer_hold = nil;
end
- flush_reasons[why or "important"]();
+ flush_reasons:with_labels(why or "important"):add(1);
session.log("debug", "Flushing buffer (%s; queue size is %d)", why or "important", session.csi_counter);
session.conn:resume_writes();
session.state = "flushing";
@@ -139,7 +136,7 @@ end
local function flush_buffer(data, session)
session.log("debug", "Flushing buffer (%s; queue size is %d)", "client activity", session.csi_counter);
- flush_reasons["client activity"]();
+ flush_reasons:with_labels("client activity"):add(1);
if session.csi_measure_buffer_hold then
session.csi_measure_buffer_hold();
session.csi_measure_buffer_hold = nil;