Software /
code /
prosody
Diff
plugins/mod_csi_simple.lua @ 11573:cb5748f94840
mod_csi_simple: convert to use new metric interface for flush reasons
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Thu, 20 May 2021 14:00:54 +0200 |
parent | 11425:fc7706fe115d |
child | 11834:f54d9abc4e14 |
line wrap: on
line diff
--- a/plugins/mod_csi_simple.lua Wed May 19 23:39:56 2021 +0200 +++ b/plugins/mod_csi_simple.lua Thu May 20 14:00:54 2021 +0200 @@ -107,14 +107,11 @@ 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 @@ 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 @@ 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;