diff options
author | Kim Alvefur <zash@zash.se> | 2020-05-09 17:47:03 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-05-09 17:47:03 +0200 |
commit | 3e50ef4da605e3203830a56bb7302ec80aa865d4 (patch) | |
tree | 1dc74c8fd07bc8781c11c6f665f216f7159d8034 /plugins/mod_csi_simple.lua | |
parent | 931adcf40c7d5afdd193cddcd565750fd384eff1 (diff) | |
download | prosody-3e50ef4da605e3203830a56bb7302ec80aa865d4.tar.gz prosody-3e50ef4da605e3203830a56bb7302ec80aa865d4.zip |
mod_csi_simple: Collect stats on flush reasons
Diffstat (limited to 'plugins/mod_csi_simple.lua')
-rw-r--r-- | plugins/mod_csi_simple.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/plugins/mod_csi_simple.lua b/plugins/mod_csi_simple.lua index c0871c8d..0c428c4a 100644 --- a/plugins/mod_csi_simple.lua +++ b/plugins/mod_csi_simple.lua @@ -103,6 +103,15 @@ 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 function manage_buffer(stanza, session) local ctr = session.csi_counter or 0; local flush, why = should_flush(stanza, session, ctr); @@ -111,6 +120,7 @@ local function manage_buffer(stanza, session) session.csi_measure_buffer_hold(); session.csi_measure_buffer_hold = nil; end + flush_reasons[why or "important"](); session.log("debug", "Flushing buffer (%s; queue size is %d)", why or "important", session.csi_counter); session.conn:resume_writes(); else @@ -123,6 +133,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"](); if session.csi_measure_buffer_hold then session.csi_measure_buffer_hold(); session.csi_measure_buffer_hold = nil; |