fix(log): adding span metadata to tokio spawned futures (#4118)

This commit is contained in:
Shankar Singh C
2024-03-27 11:46:22 +05:30
committed by GitHub
parent 7f5ad621a1
commit 070622125f
13 changed files with 115 additions and 84 deletions

View File

@ -1,5 +1,6 @@
use std::sync::{atomic, Arc};
use router_env::tracing::Instrument;
use tokio::{
sync::{mpsc, oneshot},
time::{self, Duration},
@ -68,13 +69,16 @@ impl Handler {
while self.running.load(atomic::Ordering::SeqCst) {
metrics::DRAINER_HEALTH.add(&metrics::CONTEXT, 1, &[]);
if self.store.is_stream_available(stream_index).await {
tokio::spawn(drainer_handler(
self.store.clone(),
stream_index,
self.conf.max_read_count,
self.active_tasks.clone(),
jobs_picked.clone(),
));
let _task_handle = tokio::spawn(
drainer_handler(
self.store.clone(),
stream_index,
self.conf.max_read_count,
self.active_tasks.clone(),
jobs_picked.clone(),
)
.in_current_span(),
);
}
stream_index = utils::increment_stream_index(
(stream_index, jobs_picked.clone()),
@ -116,10 +120,12 @@ impl Handler {
let redis_conn_clone = self.store.redis_conn.clone();
// Spawn a task to monitor if redis is down or not
tokio::spawn(async move { redis_conn_clone.on_error(redis_error_tx).await });
let _task_handle = tokio::spawn(
async move { redis_conn_clone.on_error(redis_error_tx).await }.in_current_span(),
);
//Spawns a task to send shutdown signal if redis goes down
tokio::spawn(redis_error_receiver(redis_error_rx, tx));
let _task_handle = tokio::spawn(redis_error_receiver(redis_error_rx, tx).in_current_span());
Ok(())
}