Mercurial > prosody-modules
diff mod_prometheus/mod_prometheus.lua @ 4542:fb4a50bf60f1
mod_prometheus: Invoke stats collection if in 'manual' mode
Since 10d13e0554f9 a special value for statistics_interval "manual"
exists, where a module is expected to invoke processing in connection to
collection of stats. This makes internal collection and exporting to
Prometheus happens at the same time with no chance of timers getting out
of sync.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 13 Apr 2021 23:53:53 +0200 |
parents | 343dc9dd70dd |
children | 64fa2dd34d43 |
line wrap: on
line diff
--- a/mod_prometheus/mod_prometheus.lua Sun Apr 11 21:59:50 2021 +0200 +++ b/mod_prometheus/mod_prometheus.lua Tue Apr 13 23:53:53 2021 +0200 @@ -11,7 +11,8 @@ local t_insert = table.insert; local t_concat = table.concat; local socket = require "socket"; -local get_stats = require "core.statsmanager".get_stats; +local statsman = require "core.statsmanager"; +local get_stats = statsman.get_stats; local function escape(text) return text:gsub("\\", "\\\\"):gsub("\"", "\\\""):gsub("\n", "\\n"); @@ -126,6 +127,9 @@ local function get_metrics(event) local response = event.response; response.headers.content_type = "text/plain; version=0.0.4"; + if statsman.collect then + statsman.collect() + end local answer = {}; for key, fields in pairs(parse_stats()) do