Mercurial > prosody-hg
diff util/startup.lua @ 13659:5abdcad8c2e0
net.adns: Collect DNS lookup timing metrics
Nice to have this in OpenMetricts instead of debug logs
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 07 Feb 2025 09:22:52 +0100 |
| parents | 94f77a1994dc |
| children | 0c7e11c11968 |
line wrap: on
line diff
--- a/util/startup.lua Thu Feb 06 17:37:59 2025 +0000 +++ b/util/startup.lua Fri Feb 07 09:22:52 2025 +0100 @@ -425,6 +425,19 @@ 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 @@ startup.load_secondary_libraries(); startup.init_promise(); startup.init_async(); + startup.instrument(); startup.init_http_client(); startup.init_data_store(); startup.init_global_protection();
