aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2025-02-07 09:22:52 +0100
committerKim Alvefur <zash@zash.se>2025-02-07 09:22:52 +0100
commitb4e8a8c6c49c7f6b4131eefa9d10d19d768b5e55 (patch)
tree98712f7f37660ddeb413be026805f8691e2422df /util
parent3d61988313d632dd5739a71119bd142fcd9c636b (diff)
downloadprosody-b4e8a8c6c49c7f6b4131eefa9d10d19d768b5e55.tar.gz
prosody-b4e8a8c6c49c7f6b4131eefa9d10d19d768b5e55.zip
net.adns: Collect DNS lookup timing metrics
Nice to have this in OpenMetricts instead of debug logs
Diffstat (limited to 'util')
-rw-r--r--util/startup.lua14
1 files changed, 14 insertions, 0 deletions
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();