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.
This commit is contained in:
Wez Furlong
2025-03-27 09:26:30 -07:00
parent 637fdc6bc0
commit 6aa18f7229
+5 -1
View File
@@ -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() => {