From a00cac5094615a486d6b2ab0c5fbdd2bac69ef97 Mon Sep 17 00:00:00 2001 From: "W.C.A. Wijngaards" Date: Tue, 3 Feb 2026 12:01:36 +0100 Subject: [PATCH] - add-prometheus-metrics, testbound implementation, and if metrics are disabled there is no http service created. --- daemon/metrics.c | 2 ++ testcode/testbound.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/daemon/metrics.c b/daemon/metrics.c index 619e20d23..f768a9da7 100644 --- a/daemon/metrics.c +++ b/daemon/metrics.c @@ -282,6 +282,8 @@ daemon_metrics_attach(struct daemon_metrics* metrics, struct worker* worker) struct metrics_acceptlist* p; if(!metrics) return 1; metrics->worker = worker; + if(!metrics->accept_list) + return 1; metrics->http_server = evhttp_new(ub_libevent_get_event_base( comm_base_internal(worker->base))); diff --git a/testcode/testbound.c b/testcode/testbound.c index 063037df4..4d5e38765 100644 --- a/testcode/testbound.c +++ b/testcode/testbound.c @@ -664,6 +664,42 @@ void remote_get_opt_ssl(char* ATTR_UNUSED(str), void* ATTR_UNUSED(arg)) log_assert(0); } +/* fake metrics */ +struct daemon_metrics* daemon_metrics_create(void) +{ + return (struct daemon_metrics*)calloc(1, sizeof(void*)); +} + +void daemon_metrics_delete(struct daemon_metrics* m) +{ + if(!m) return; + free(m); +} + +void daemon_metrics_close_ports(struct daemon_metrics* ATTR_UNUSED(m)) +{ + /* nothing */ +} + +void daemon_metrics_detach(struct daemon_metrics* ATTR_UNUSED(m)) +{ + /* nothing */ +} + +int daemon_metrics_open_ports(struct daemon_metrics* ATTR_UNUSED(m), + struct config_file* ATTR_UNUSED(cfg)) +{ + /* nothing */ + return 1; +} + +int daemon_metrics_attach(struct daemon_metrics* ATTR_UNUSED(m), + struct worker* ATTR_UNUSED(worker)) +{ + /* nothing */ + return 1; +} + #ifdef UB_ON_WINDOWS void wsvc_command_option(const char* ATTR_UNUSED(wopt), const char* ATTR_UNUSED(cfgfile), int ATTR_UNUSED(v),