Giter Site home page Giter Site logo

Void spans about tracing HOT 3 CLOSED

tokio-rs avatar tokio-rs commented on August 25, 2024
Void spans

from tracing.

Comments (3)

hawkw avatar hawkw commented on August 25, 2024 2

Feature Request

Crates

tracing-core?

I think this would be a change in tracing rather than tracing-core; the Span type is from tracing :)

[...]
The solution outlined above works okay, but it'd be nicer if there existed a sort of "void" Span that was free to produce, and that did nothing when entered. Ideally I would also not need to give Metadata for it, since it shouldn't ever be used.

I think we could implement this rather easily, actually. It could look like this:

impl Span { 
    // ...
 
    pub fn none() -> Self {
        let meta = $crate::callsite! {
            name: "no span"
            kind: Kind::SPAN,
            target: ""
            level: Level::TRACE,
            fields: 
        }.metadata();
        Self {
            meta,
            inner: None,
        }
    }

    // ...
}

We could then hack the log support to not log for spans originating at the empty callsite.

We would need to make sure the documentation clearly distinguishes between Span::new_disabled and Span::none.

Name is, of course, open to bikeshedding.

from tracing.

hawkw avatar hawkw commented on August 25, 2024 1

As an alternative, we could also move the metadata field optional. I think that might be the right approach. It'd make life easier for a Span::current function in the case that we're not currently in a span; otherwise, we'd have to return Option<Span>. And, since it's a reference, it shouldn't make the struct bigger to add an option.

from tracing.

jonhoo avatar jonhoo commented on August 25, 2024

I think this would be a change in tracing rather than tracing-core; the Span type is from tracing :)

Updated!

from tracing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.