Skip to content

Commit 5a50a57

Browse files
committed
Remove .with_current_subscriber() calls
Those calls were introduced in e557095, with message: ``` Now, when the driver spawns a task to run a new future on it, that future will use the same subscriber as the code that spawned the task in the first place. ``` There is unfortunately no explanation about when it is necessary. I don't see any problems after removing those - logs are still collected correctly using a tracing subscriber. Those calls however have a harmful side-effect: they prevent usage of `log` loggers to listen to driver logs using `log` feature in `tracing` crate. After reporting the problem to `tracing` crate: tokio-rs/tracing#2913 one of maintainers said that using `.with_current_subscriber()` in a library is not necessary in general. As I don't see any issue caused by removing these calls, but their existence cause an issue, they are removed in this commit.
1 parent 1d78cbe commit 5a50a57

File tree

9 files changed

+19
-30
lines changed

9 files changed

+19
-30
lines changed

scylla-proxy/examples/cmdline.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use std::{
1313
};
1414

1515
use scylla_proxy::{Node, Proxy, ShardAwareness};
16-
use tracing::instrument::WithSubscriber;
1716

1817
fn init_logger() {
1918
tracing_subscriber::fmt::fmt()
@@ -53,7 +52,7 @@ async fn main() {
5352
None,
5453
None,
5554
)]);
56-
let running_proxy = proxy.run().with_current_subscriber().await.unwrap();
55+
let running_proxy = proxy.run().await.unwrap();
5756

5857
pause().await;
5958
running_proxy.finish().await.unwrap();

scylla-proxy/examples/identity_proxy.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::{net::SocketAddr, str::FromStr};
22

33
use scylla_proxy::{Node, Proxy, ShardAwareness};
4-
use tracing::instrument::WithSubscriber;
54

65
fn init_logger() {
76
tracing_subscriber::fmt::fmt()
@@ -30,7 +29,7 @@ async fn main() {
3029
.build(),
3130
)
3231
.build();
33-
let running_proxy = proxy.run().with_current_subscriber().await.unwrap();
32+
let running_proxy = proxy.run().await.unwrap();
3433

3534
pause().await;
3635
running_proxy.finish().await.unwrap();

scylla-proxy/examples/identity_shard_aware_proxy.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::{net::SocketAddr, str::FromStr};
22

33
use scylla_proxy::{Node, Proxy, ShardAwareness};
4-
use tracing::instrument::WithSubscriber;
54

65
fn init_logger() {
76
tracing_subscriber::fmt::fmt()
@@ -27,7 +26,7 @@ async fn main() {
2726
None,
2827
None,
2928
)]);
30-
let running_proxy = proxy.run().with_current_subscriber().await.unwrap();
29+
let running_proxy = proxy.run().await.unwrap();
3130

3231
pause().await;
3332
running_proxy.finish().await.unwrap();

scylla/src/transport/cluster.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use std::collections::{HashMap, HashSet};
2424
use std::net::SocketAddr;
2525
use std::sync::Arc;
2626
use std::time::Duration;
27-
use tracing::instrument::WithSubscriber;
2827
use tracing::{debug, warn};
2928
use uuid::Uuid;
3029

@@ -206,7 +205,7 @@ impl Cluster {
206205
};
207206

208207
let (fut, worker_handle) = worker.work().remote_handle();
209-
tokio::spawn(fut.with_current_subscriber());
208+
tokio::spawn(fut);
210209

211210
let result = Cluster {
212211
data: cluster_data,
@@ -647,7 +646,7 @@ impl ClusterWorker {
647646

648647
let cluster_data = self.cluster_data.load_full();
649648
let use_keyspace_future = Self::handle_use_keyspace_request(cluster_data, request);
650-
tokio::spawn(use_keyspace_future.with_current_subscriber());
649+
tokio::spawn(use_keyspace_future);
651650
},
652651
None => return, // If use_keyspace_channel was closed then cluster was dropped, we can stop working
653652
}

scylla/src/transport/connection.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use tokio::io::{split, AsyncRead, AsyncWrite, AsyncWriteExt, BufReader, BufWrite
1313
use tokio::net::{TcpSocket, TcpStream};
1414
use tokio::sync::{mpsc, oneshot};
1515
use tokio::time::Instant;
16-
use tracing::instrument::WithSubscriber;
1716
use tracing::{debug, error, trace, warn};
1817
use uuid::Uuid;
1918

@@ -1090,7 +1089,7 @@ impl Connection {
10901089
node_address,
10911090
)
10921091
.remote_handle();
1093-
tokio::task::spawn(task.with_current_subscriber());
1092+
tokio::task::spawn(task);
10941093
return Ok(handle);
10951094
}
10961095

@@ -1104,7 +1103,7 @@ impl Connection {
11041103
node_address,
11051104
)
11061105
.remote_handle();
1107-
tokio::task::spawn(task.with_current_subscriber());
1106+
tokio::task::spawn(task);
11081107
Ok(handle)
11091108
}
11101109

scylla/src/transport/connection_pool.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use std::sync::{Arc, RwLock, Weak};
2727
use std::time::Duration;
2828

2929
use tokio::sync::{broadcast, mpsc, Notify};
30-
use tracing::instrument::WithSubscriber;
3130
use tracing::{debug, error, trace, warn};
3231

3332
/// The target size of a per-node connection pool.
@@ -212,7 +211,7 @@ impl NodeConnectionPool {
212211

213212
let conns = refiller.get_shared_connections();
214213
let (fut, refiller_handle) = refiller.run(use_keyspace_request_receiver).remote_handle();
215-
tokio::spawn(fut.with_current_subscriber());
214+
tokio::spawn(fut);
216215

217216
Self {
218217
conns,
@@ -1138,17 +1137,14 @@ impl PoolRefiller {
11381137
Err(QueryError::IoError(io_error.unwrap()))
11391138
};
11401139

1141-
tokio::task::spawn(
1142-
async move {
1143-
let res = fut.await;
1144-
match &res {
1145-
Ok(()) => debug!("[{}] Successfully changed current keyspace", address),
1146-
Err(err) => warn!("[{}] Failed to change keyspace: {:?}", address, err),
1147-
}
1148-
let _ = response_sender.send(res);
1140+
tokio::task::spawn(async move {
1141+
let res = fut.await;
1142+
match &res {
1143+
Ok(()) => debug!("[{}] Successfully changed current keyspace", address),
1144+
Err(err) => warn!("[{}] Failed to change keyspace: {:?}", address, err),
11491145
}
1150-
.with_current_subscriber(),
1151-
);
1146+
let _ = response_sender.send(res);
1147+
});
11521148
}
11531149

11541150
// Requires the keyspace to be set

scylla/src/transport/iterator.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use scylla_cql::types::serialize::row::SerializedValues;
1616
use std::result::Result;
1717
use thiserror::Error;
1818
use tokio::sync::mpsc;
19-
use tracing::instrument::WithSubscriber;
2019

2120
use super::errors::QueryError;
2221
use super::execution_profile::ExecutionProfileInner;
@@ -387,7 +386,7 @@ impl RowIterator {
387386
worker_task: impl Future<Output = PageSendAttemptedProof> + Send + 'static,
388387
mut receiver: mpsc::Receiver<Result<ReceivedPage, QueryError>>,
389388
) -> Result<RowIterator, QueryError> {
390-
tokio::task::spawn(worker_task.with_current_subscriber());
389+
tokio::task::spawn(worker_task);
391390

392391
// This unwrap is safe because:
393392
// - The future returned by worker.work sends at least one item

scylla/src/transport/load_balancing/default.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,7 @@ mod latency_awareness {
22692269
use itertools::Either;
22702270
use scylla_cql::errors::{DbError, QueryError};
22712271
use tokio::time::{Duration, Instant};
2272-
use tracing::{instrument::WithSubscriber, trace, warn};
2272+
use tracing::{trace, warn};
22732273
use uuid::Uuid;
22742274

22752275
use crate::{load_balancing::NodeRef, routing::Shard, transport::node::Node};
@@ -2454,7 +2454,7 @@ mod latency_awareness {
24542454
}
24552455
}
24562456
.remote_handle();
2457-
tokio::task::spawn(updater_fut.with_current_subscriber());
2457+
tokio::task::spawn(updater_fut);
24582458

24592459
Self {
24602460
_updater_handle: Some(updater_handle),

scylla/tests/integration/utils.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::collections::HashMap;
33
use std::env;
44
use std::net::SocketAddr;
55
use std::str::FromStr;
6-
use tracing::instrument::WithSubscriber;
76

87
use scylla_proxy::{Node, Proxy, ProxyError, RunningProxy, ShardAwareness};
98

@@ -53,7 +52,7 @@ where
5352
);
5453

5554
let translation_map = proxy.translation_map();
56-
let running_proxy = proxy.run().with_current_subscriber().await.unwrap();
55+
let running_proxy = proxy.run().await.unwrap();
5756

5857
let running_proxy = test(
5958
[proxy1_uri, proxy2_uri, proxy3_uri],

0 commit comments

Comments
 (0)