Skip to content

Commit 234285a

Browse files
committed
chore: with_verbose_retrace => with_span_retrace
1 parent c80a6b8 commit 234285a

File tree

4 files changed

+38
-42
lines changed

4 files changed

+38
-42
lines changed

examples/basic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ fn main() {
1111
.with_thread_ids(true)
1212
.with_verbose_exit(true)
1313
.with_verbose_entry(true)
14-
.with_span_modes(true)
1514
.with_targets(true);
1615

1716
let subscriber = Registry::default().with(layer);

examples/concurrent.rs

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ fn main() {
1818
.with_thread_ids(true)
1919
.with_verbose_exit(true)
2020
.with_verbose_entry(true)
21-
.with_verbose_retrace(true)
21+
.with_span_retrace(true)
22+
.with_deferred_spans(true)
2223
.with_deferred_spans(false)
2324
.with_span_modes(true)
2425
.with_targets(true);
@@ -48,34 +49,32 @@ fn main() {
4849
});
4950

5051
debug!("starting countdowns");
51-
debug_span!("countdowns").in_scope(
52-
|| {
53-
let mut countdown_a = CountdownFuture {
54-
label: "a",
55-
count: 3,
56-
}
57-
.instrument(span!(Level::DEBUG, "countdown_a"))
58-
.fuse();
59-
60-
let mut countdown_b = CountdownFuture {
61-
label: "b",
62-
count: 5,
63-
}
64-
.instrument(span!(Level::DEBUG, "countdown_b"))
65-
.fuse();
66-
67-
// We don't care if the futures are ready, as we poll manually
68-
let waker = futures::task::noop_waker();
69-
let mut cx = Context::from_waker(&waker);
70-
71-
let _ = countdown_a.poll_unpin(&mut cx);
72-
let _ = countdown_b.poll_unpin(&mut cx);
73-
74-
std::thread::sleep(std::time::Duration::from_millis(300));
75-
76-
let _ = countdown_b.poll_unpin(&mut cx);
77-
}, //
78-
);
52+
debug_span!("countdowns").in_scope(|| {
53+
let mut countdown_a = CountdownFuture {
54+
label: "a",
55+
count: 3,
56+
}
57+
.instrument(span!(Level::DEBUG, "countdown_a"))
58+
.fuse();
59+
60+
let mut countdown_b = CountdownFuture {
61+
label: "b",
62+
count: 5,
63+
}
64+
.instrument(span!(Level::DEBUG, "countdown_b"))
65+
.fuse();
66+
67+
// We don't care if the futures are ready, as we poll manually
68+
let waker = futures::task::noop_waker();
69+
let mut cx = Context::from_waker(&waker);
70+
71+
let _ = countdown_a.poll_unpin(&mut cx);
72+
let _ = countdown_b.poll_unpin(&mut cx);
73+
74+
std::thread::sleep(std::time::Duration::from_millis(300));
75+
76+
let _ = countdown_b.poll_unpin(&mut cx);
77+
});
7978

8079
tracing::info!("finished countdowns");
8180

src/format.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ pub struct Config {
5353
/// Whether to print the current span before exiting it.
5454
pub verbose_exit: bool,
5555
/// Print the path leading up to a span if a different span was entered concurrently
56-
pub verbose_retrace: bool,
56+
pub span_retrace: bool,
5757
/// Whether to print squiggly brackets (`{}`) around the list of fields in a span.
5858
pub bracketed_fields: bool,
59-
59+
/// Defer printing a span until an event is generated inside of it
6060
pub deferred_spans: bool,
61-
61+
/// Print a label of the span mode (open/close etc).
6262
pub span_modes: bool,
6363
}
6464

@@ -110,9 +110,9 @@ impl Config {
110110
}
111111
}
112112

113-
pub fn with_verbose_retrace(self, verbose_retrace: bool) -> Self {
113+
pub fn with_span_retrace(self, enabled: bool) -> Self {
114114
Self {
115-
verbose_retrace,
115+
span_retrace: enabled,
116116
..self
117117
}
118118
}
@@ -173,7 +173,7 @@ impl Default for Config {
173173
wraparound: usize::max_value(),
174174
verbose_entry: false,
175175
verbose_exit: false,
176-
verbose_retrace: false,
176+
span_retrace: false,
177177
bracketed_fields: false,
178178
deferred_spans: false,
179179
span_modes: false,

src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ where
204204
/// the meantime
205205
/// This helps during concurrent or multi-threaded events where threads are entered, but not
206206
/// necessarily *exited* before other *divergent* spans are entered and generating events.
207-
pub fn with_verbose_retrace(self, verbose_retrace: bool) -> Self {
207+
pub fn with_span_retrace(self, enabled: bool) -> Self {
208208
Self {
209-
config: self.config.with_verbose_retrace(verbose_retrace),
209+
config: self.config.with_span_retrace(enabled),
210210
..self
211211
}
212212
}
@@ -394,7 +394,7 @@ where
394394
let bufs = &mut *guard;
395395

396396
if let Some((span_id, current_span)) = &span {
397-
if self.config.verbose_retrace
397+
if self.config.span_retrace
398398
|| current_span
399399
.extensions()
400400
.get::<Data>()
@@ -406,8 +406,6 @@ where
406406

407407
let old_span_id = bufs.current_span.replace((*span_id).clone());
408408

409-
eprintln!("Old span: {old_span_id:?}");
410-
411409
if Some(*span_id) != old_span_id.as_ref() {
412410
let old_span = old_span_id.as_ref().and_then(|v| ctx.span(v));
413411

@@ -429,7 +427,7 @@ where
429427
bufs,
430428
&ctx,
431429
SpanMode::Retrace {
432-
verbose: self.config.verbose_retrace,
430+
verbose: self.config.span_retrace,
433431
},
434432
)
435433
}

0 commit comments

Comments
 (0)