# HG changeset patch # User Kim Alvefur # Date 1589039223 -7200 # Node ID 8889d5037acac684afb931a8322c5b8eb2e7b61a # Parent 67a09706e56e8a82e8098874f0230d8c705f7d4e mod_csi_simple: Collect stats on flush reasons diff -r 67a09706e56e -r 8889d5037aca plugins/mod_csi_simple.lua --- a/plugins/mod_csi_simple.lua Sat May 09 17:45:45 2020 +0200 +++ b/plugins/mod_csi_simple.lua Sat May 09 17:47:03 2020 +0200 @@ -103,6 +103,15 @@ 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 @@ 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 @@ 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;