# HG changeset patch # User Kim Alvefur # Date 1618350833 -7200 # Node ID fb4a50bf60f10e4e436bb9d84c6bcd72a64aa88c # Parent 140cda94c34211f6bc3fa4ec03e1a251be451f14 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. diff -r 140cda94c342 -r fb4a50bf60f1 mod_prometheus/mod_prometheus.lua --- 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