From 6aa18f7229e3bb99dcc938c6f8405e16fa5d6bc2 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 27 Mar 2025 09:26:30 -0700 Subject: [PATCH] fix: total_connections_denied{service="esmtp_listener"} always reaped This is an regression introduced by the recent changes to support reloading tls parameters in the esmtp listener. We need to ensure that the counter is kept alive for the duration of the listener so that it doesn't get immediately repead out of the reported set of metrics. --- crates/kumod/src/smtp_server.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/kumod/src/smtp_server.rs b/crates/kumod/src/smtp_server.rs index e1bdf73e..dbf0c92a 100644 --- a/crates/kumod/src/smtp_server.rs +++ b/crates/kumod/src/smtp_server.rs @@ -473,7 +473,7 @@ impl EsmtpListenerParams { } pub async fn run(self) -> anyhow::Result<()> { - connection_gauge(); + let connection_gauge = connection_gauge(); let listener = TcpListener::bind(&self.listen) .await @@ -490,6 +490,10 @@ impl EsmtpListenerParams { tokio::select! { _ = shutting_down.shutting_down() => { tracing::info!("smtp listener on {addr:?} -> stopping"); + // Keep the connection gauge alive for the lifetime + // of this listener so that it doesn't get reaped out + // of the reported set of metrics + drop(connection_gauge); return Ok::<(), anyhow::Error>(()); } result = listener.accept() => {