From 8aaa3105e6bc8f8e575f11781e04529a7e35bdfe Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 19 Nov 2024 07:42:45 -0700 Subject: [PATCH] make session_id a first class member of Dispatcher previously, we'd generate a trace_id only in the SmtpDispatcher for the tracing subsystem. We want to capture a session id in the logs, so the first step is to formalize this field. refs: https://github.com/KumoCorp/kumomta/issues/316 --- crates/kumod/src/ready_queue.rs | 3 +++ crates/kumod/src/smtp_dispatcher.rs | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/kumod/src/ready_queue.rs b/crates/kumod/src/ready_queue.rs index be3f369a..962f153e 100644 --- a/crates/kumod/src/ready_queue.rs +++ b/crates/kumod/src/ready_queue.rs @@ -39,6 +39,7 @@ use throttle::ThrottleSpec; use tokio::sync::Notify; use tokio::task::JoinHandle; use tracing::instrument; // TODO move to here +use uuid::Uuid; static MANAGER: LazyLock> = LazyLock::new(|| StdMutex::new(ReadyQueueManager::new())); @@ -933,6 +934,7 @@ pub struct Dispatcher { pub msgs: Vec, pub delivery_protocol: String, pub suspended: Option, + pub session_id: Uuid, leases: Vec, batch_started: Option, } @@ -1029,6 +1031,7 @@ impl Dispatcher { leases, suspended: None, batch_started: None, + session_id: Uuid::new_v4(), }; let mut queue_dispatcher: Box = match &queue_config.borrow().protocol { diff --git a/crates/kumod/src/smtp_dispatcher.rs b/crates/kumod/src/smtp_dispatcher.rs index e0b17b34..705fe7c6 100644 --- a/crates/kumod/src/smtp_dispatcher.rs +++ b/crates/kumod/src/smtp_dispatcher.rs @@ -25,7 +25,6 @@ use serde::{Deserialize, Serialize}; use std::net::SocketAddr; use std::sync::{Arc, LazyLock}; use tracing::Level; -use uuid::Uuid; static BROKEN_TLS_BY_SITE: LazyLock> = LazyLock::new(|| LruCacheWithTtl::new_named("smtp_dispatcher_broken_tls", 64 * 1024)); @@ -97,8 +96,6 @@ impl SmtpDispatcher { }, }; - let trace_id = Uuid::new_v4().to_string(); - let addresses = if proto_config.mx_list.is_empty() { dispatcher .mx @@ -128,7 +125,7 @@ impl SmtpDispatcher { let tracer = Arc::new(SmtpClientTracerImpl::new(serde_json::json!({ "egress_pool": dispatcher.egress_pool.to_string(), "egress_source": dispatcher.egress_source.name.to_string(), - "id": trace_id, + "id": dispatcher.session_id.to_string(), "ready_queue_name": dispatcher.name.to_string(), "mx_plan": addresses.clone(), })));