mirror of
https://github.com/tokio-rs/tracing.git
synced 2026-01-25 04:16:18 +00:00
Migrate layer crates to use SpanRef::scope
This commit is contained in:
@@ -90,8 +90,7 @@ where
|
||||
let span = subscriber
|
||||
.span(id)
|
||||
.expect("registry should have a span for the current ID");
|
||||
let parents = span.parents();
|
||||
for span in std::iter::once(span).chain(parents) {
|
||||
for span in span.scope().from_root() {
|
||||
let cont = if let Some(fields) = span.extensions().get::<FormattedFields<F>>() {
|
||||
f(span.metadata(), fields.fields.as_str())
|
||||
} else {
|
||||
|
||||
@@ -398,12 +398,10 @@ where
|
||||
|
||||
let first = ctx.span(id).expect("expected: span id exists in registry");
|
||||
|
||||
if !self.config.empty_samples && first.from_root().count() == 0 {
|
||||
if !self.config.empty_samples && first.parent().is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
let parents = first.from_root();
|
||||
|
||||
let mut stack = String::new();
|
||||
|
||||
if !self.config.threads_collapsed {
|
||||
@@ -412,7 +410,11 @@ where
|
||||
stack += "all-threads";
|
||||
}
|
||||
|
||||
for parent in parents {
|
||||
let mut parents = first.scope();
|
||||
parents
|
||||
.next()
|
||||
.expect("expected: scope begins with leaf scope");
|
||||
for parent in parents.from_root() {
|
||||
stack += "; ";
|
||||
write(&mut stack, parent, &self.config).expect("expected: write to String never fails");
|
||||
}
|
||||
@@ -444,7 +446,6 @@ where
|
||||
|
||||
let samples = self.time_since_last_event();
|
||||
let first = expect!(ctx.span(&id), "expected: span id exists in registry");
|
||||
let parents = first.from_root();
|
||||
|
||||
let mut stack = String::new();
|
||||
if !self.config.threads_collapsed {
|
||||
@@ -452,20 +453,15 @@ where
|
||||
} else {
|
||||
stack += "all-threads";
|
||||
}
|
||||
stack += "; ";
|
||||
|
||||
for parent in parents {
|
||||
for parent in first.scope().from_root() {
|
||||
stack += "; ";
|
||||
expect!(
|
||||
write(&mut stack, parent, &self.config),
|
||||
"expected: write to String never fails"
|
||||
);
|
||||
stack += "; ";
|
||||
}
|
||||
|
||||
expect!(
|
||||
write(&mut stack, first, &self.config),
|
||||
"expected: write to String never fails"
|
||||
);
|
||||
expect!(
|
||||
write!(&mut stack, " {}", samples.as_nanos()),
|
||||
"expected: write to String never fails"
|
||||
|
||||
@@ -126,7 +126,7 @@ where
|
||||
let span = ctx.span(id).expect("unknown span");
|
||||
let mut buf = Vec::with_capacity(256);
|
||||
|
||||
let depth = span.parents().count();
|
||||
let depth = span.scope().skip(1).count();
|
||||
|
||||
writeln!(buf, "S{}_NAME", depth).unwrap();
|
||||
put_value(&mut buf, span.name().as_bytes());
|
||||
@@ -143,7 +143,7 @@ where
|
||||
|
||||
fn on_record(&self, id: &Id, values: &Record, ctx: Context<S>) {
|
||||
let span = ctx.span(id).expect("unknown span");
|
||||
let depth = span.parents().count();
|
||||
let depth = span.scope().skip(1).count();
|
||||
let mut exts = span.extensions_mut();
|
||||
let buf = &mut exts.get_mut::<SpanFields>().expect("missing fields").0;
|
||||
values.record(&mut SpanVisitor {
|
||||
@@ -157,7 +157,11 @@ where
|
||||
let mut buf = Vec::with_capacity(256);
|
||||
|
||||
// Record span fields
|
||||
for span in ctx.scope() {
|
||||
for span in ctx
|
||||
.lookup_current()
|
||||
.into_iter()
|
||||
.flat_map(|span| span.scope())
|
||||
{
|
||||
let exts = span.extensions();
|
||||
let fields = exts.get::<SpanFields>().expect("missing fields");
|
||||
buf.extend_from_slice(&fields.0);
|
||||
|
||||
Reference in New Issue
Block a user