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
This commit is contained in:
Wez Furlong
2024-11-19 07:42:45 -07:00
parent 992ffbd470
commit 8aaa3105e6
2 changed files with 4 additions and 4 deletions
+3
View File
@@ -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<StdMutex<ReadyQueueManager>> =
LazyLock::new(|| StdMutex::new(ReadyQueueManager::new()));
@@ -933,6 +934,7 @@ pub struct Dispatcher {
pub msgs: Vec<Message>,
pub delivery_protocol: String,
pub suspended: Option<AdminSuspendReadyQEntryRef>,
pub session_id: Uuid,
leases: Vec<LimitLease>,
batch_started: Option<tokio::time::Instant>,
}
@@ -1029,6 +1031,7 @@ impl Dispatcher {
leases,
suspended: None,
batch_started: None,
session_id: Uuid::new_v4(),
};
let mut queue_dispatcher: Box<dyn QueueDispatcher> = match &queue_config.borrow().protocol {
+1 -4
View File
@@ -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<LruCacheWithTtl<String, ()>> =
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(),
})));