Skip to content

Commit 24833e1

Browse files
committed
ref: remove some default traces + cfg feature on tracing for instrument
1 parent 262b36a commit 24833e1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/robust_provider/provider.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use backon::{ExponentialBuilder, Retryable};
1212
use futures::TryFutureExt;
1313
use thiserror::Error;
1414
use tokio::time::{error as TokioError, timeout};
15+
#[cfg(feature = "tracing")]
1516
use tracing::instrument;
1617

1718
use crate::robust_provider::RobustSubscription;
@@ -322,7 +323,7 @@ impl<N: Network> RobustProvider<N> {
322323
.await
323324
}
324325

325-
#[instrument(level = "trace", skip(self, operation, last_error))]
326+
#[cfg_attr(feature = "tracing", instrument(level = "trace", skip(self, operation, last_error)))]
326327
pub(crate) async fn try_fallback_providers<T: Debug, F, Fut>(
327328
&self,
328329
operation: F,
@@ -338,7 +339,7 @@ impl<N: Network> RobustProvider<N> {
338339
.map(|(value, _idx)| value)
339340
}
340341

341-
#[instrument(level = "trace", skip(self, operation, last_error))]
342+
#[cfg_attr(feature = "tracing", instrument(level = "trace", skip(self, operation, last_error)))]
342343
pub(crate) async fn try_fallback_providers_from<T: Debug, F, Fut>(
343344
&self,
344345
operation: F,
@@ -362,7 +363,7 @@ impl<N: Network> RobustProvider<N> {
362363
continue;
363364
}
364365

365-
tracing::trace!(
366+
trace!(
366367
fallback_provider_index = fallback_idx + 1,
367368
total_num_fallbacks = num_fallbacks,
368369
"Attempting fallback provider"
@@ -384,7 +385,7 @@ impl<N: Network> RobustProvider<N> {
384385
}
385386
}
386387

387-
tracing::error!("All providers exhausted");
388+
tracing::error!("All providers failed");
388389

389390
Err(last_error)
390391
}

src/robust_provider/subscription.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::{
44
task::{Context, Poll, ready},
55
time::{Duration, Instant},
66
};
7+
#[cfg(feature = "tracing")]
78
use tracing::instrument;
89

910
use alloy::{
@@ -133,7 +134,7 @@ impl<N: Network> RobustSubscription<N> {
133134

134135
/// Try to reconnect to the primary provider if enough time has elapsed.
135136
/// Returns true if reconnection was successful, false if it's not time yet or if it failed.
136-
#[instrument(level = "trace", skip(self))]
137+
#[cfg_attr(feature = "tracing", instrument(level = "trace", skip(self)))]
137138
async fn try_reconnect_to_primary(&mut self, force: bool) -> bool {
138139
// Check if we should attempt reconnection
139140
let should_reconnect = force ||
@@ -148,8 +149,6 @@ impl<N: Network> RobustSubscription<N> {
148149
return false;
149150
}
150151

151-
trace!("Attempting to reconnect to primary provider");
152-
153152
let operation =
154153
move |provider: RootProvider<N>| async move { provider.subscribe_blocks().await };
155154

0 commit comments

Comments
 (0)