From b4e8a8c6c49c7f6b4131eefa9d10d19d768b5e55 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 7 Feb 2025 09:22:52 +0100 Subject: net.adns: Collect DNS lookup timing metrics Nice to have this in OpenMetricts instead of debug logs --- util/startup.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'util') diff --git a/util/startup.lua b/util/startup.lua index 2fa2d0b2..34c2f733 100644 --- a/util/startup.lua +++ b/util/startup.lua @@ -425,6 +425,19 @@ function startup.init_async() async.set_schedule_function(timer.add_task); end +function startup.instrument() + local statsmanager = require "prosody.core.statsmanager"; + local timed = require"prosody.util.openmetrics".timed; + + local adns = require "prosody.net.adns"; + if adns.instrument then + local m = statsmanager.metric("histogram", "prosody_dns", "seconds", "DNS lookups", { "qclass"; "qtype" }, { + buckets = { 1 / 1024; 1 / 256; 1 / 64; 1 / 16; 1 / 4; 1; 4 }; + }); + adns.instrument(function(qclass, qtype) return timed(m:with_labels(qclass, qtype)); end); + end +end + function startup.init_data_store() require "prosody.core.storagemanager"; end @@ -922,6 +935,7 @@ function startup.prosody() startup.load_secondary_libraries(); startup.init_promise(); startup.init_async(); + startup.instrument(); startup.init_http_client(); startup.init_data_store(); startup.init_global_protection(); -- cgit v1.2.3