Giter Site home page Giter Site logo

Comments (5)

carllerche avatar carllerche commented on August 25, 2024 1

We really need to figure out how tracing fits in with spawning. Obviously, Tokio can help and provide hooks :)

from tracing.

hawkw avatar hawkw commented on August 25, 2024

This is a great idea, and definitely something the tokio-trace-futurescrate should be able to provide by way of an extension trait implemented for Span. Thanks for the suggestion 👍

from tracing.

hawkw avatar hawkw commented on August 25, 2024

Another potential solution, which would be more general, is to add a method to the Instrument API to instrument a future in the current span. This way, you could say something like

span!("compile").enter(|| {
    let task = do_some_work();
    spawn(Box::new(task.in_current_span()));
});

However, we can't actually implement something like this with the current iteration of the Subscriber API as it doesn't currently specify a method to return the current span (something which we've had in the past). There's been some discussion of bringing something like that back, so if we do add a function for getting the current span, we could provide an Instrument::in_current.

With that said, I'm happy to add an enter_instrument-type function to Span in the short term, since it seems like there's a practical use-case for it, regardless of whether or not the more general solution becomes possible later.

from tracing.

carllerche avatar carllerche commented on August 25, 2024

Another option might be something like:

let task = info_future!("compile", {
   do_work()
});

spawn(task);

from tracing.

carllerche avatar carllerche commented on August 25, 2024

I agree we need to figure this out though...

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.