Skip to content

Commit c6c4d38

Browse files
committed
bind span expression to avoid multiple evaluation
1 parent a3c4a5b commit c6c4d38

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/lro/src/internal/tracing.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,18 @@ macro_rules! record_polling_attributes {
105105
($span:expr) => {
106106
#[cfg(google_cloud_unstable_tracing)]
107107
{
108-
if let Ok(attempt) = $crate::POLL_ATTEMPT_COUNT.try_with(|c| *c) {
109-
$span.record("gcp.longrunning.poll_attempt_count", attempt);
110-
$span.record("gcp.longrunning.done", false);
108+
if let Some(recorder) = $crate::LroRecorder::current() {
109+
if let Some(attempt) = recorder.attempt_count() {
110+
let span = &$span;
111+
span.record("gcp.longrunning.poll_attempt_count", attempt);
112+
span.record("gcp.longrunning.done", false);
113+
}
111114
}
112115
}
116+
#[cfg(not(google_cloud_unstable_tracing))]
117+
{
118+
let _ = &$span;
119+
}
113120
};
114121
}
115122

0 commit comments

Comments
 (0)