fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
        let span = ctx.span(id).expect("Span not found, this is a bug");

        // We want to inherit the fields from the parent span, if there is one.
        let mut visitor = if let Some(parent_span) = span.parent() {
            // Extensions can be used to associate arbitrary data to a span.
            // We'll use it to store our representation of its fields.
            // We create a copy of the parent visitor!
            let mut extensions = parent_span.extensions_mut();
            extensions
                .get_mut::<JsonStorage>()
                .map(|v| v.to_owned())
                .unwrap_or_default()
        } else {
            JsonStorage::default()
        };

        let mut extensions = span.extensions_mut();

        // Register all fields.
        // Fields on the new span should override fields on the parent span if there is a conflict.
        attrs.record(&mut visitor);
        // Associate the visitor with the Span for future usage via the Span's extensions
        extensions.insert(visitor);
    }
/// Span creation.
/// This is the only occasion we have to store the fields attached to the span
/// given that they might have been borrowed from the surrounding context.
Span creation.
This is the only occasion we have to store the fields attached to the span
given that they might have been borrowed from the surrounding context.
Span creation . This is the only occasion we have to store the fields attached to the span given that they might have been borrowed from the surrounding context .
fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
        let span = ctx.span(id).expect("Span not found, this is a bug");
        // We want to inherit the fields from the parent span, if there is one.
        let mut visitor = if let Some(parent_span) = span.parent() {
            // Extensions can be used to associate arbitrary data to a span.
            // We'll use it to store our representation of its fields.
            // We create a copy of the parent visitor!
            let mut extensions = parent_span.extensions_mut();
            extensions
                .get_mut::<JsonStorage>()
                .map(|v| v.to_owned())
                .unwrap_or_default()
        } else {
            JsonStorage::default()
        };
        let mut extensions = span.extensions_mut();
        // Register all fields.
        // Fields on the new span should override fields on the parent span if there is a conflict.
        attrs.record(&mut visitor);
        // Associate the visitor with the Span for future usage via the Span's extensions
        extensions.insert(visitor);
    }
fn on_new_span ( & self , attrs : & Attributes < ' _ > , id : & Id , ctx : Context < ' _ , S > ) { let span = ctx . span ( id ) . expect ( " " ) ; // We want to inherit the fields from the parent span, if there is one. let mut visitor = if let Some ( parent_span ) = span . parent ( ) { // Extensions can be used to associate arbitrary data to a span. // We'll use it to store our representation of its fields. // We create a copy of the parent visitor! let mut extensions = parent_span . extensions_mut ( ) ; extensions . get_mut :: < JsonStorage > ( ) . map ( | v | v . to_owned ( ) ) . unwrap_or_default ( ) } else { JsonStorage :: default ( ) } ; let mut extensions = span . extensions_mut ( ) ; // Register all fields. // Fields on the new span should override fields on the parent span if there is a conflict. attrs . record ( & mut visitor ) ; // Associate the visitor with the Span for future usage via the Span's extensions extensions . insert ( visitor ) ; }
Span creation.
Span creation .
&self
attrs
&Attributes<'_>
id
&Id
ctx
Context<'_, S>
&self
attrs
&Attributes<'_>
id
&Id
ctx
Context<'_, S>