Giter VIP home page Giter VIP logo

Comments (3)

seanmonstar avatar seanmonstar commented on August 15, 2024

I assume you mean that at tokio::spawn, if the user uses essentially tokio::spawn(future.instrument(span)), that span's user-set values would be worth including, which I agree. How would we detect that? I at first thought since F: 'static, we could check the TypeId or downcast, but it would be tracing::Instrumented<T>, which would make it a type we couldn't really check for in that way.

There's also the question of how "deep" should we try to sniff. Like, if someone spawns a Box<dyn Future> that was instrumented before boxed, that'd be helpful. They might also wrap an instrumented future in a tiny combinator. But how far do we go?

from console.

hawkw avatar hawkw commented on August 15, 2024

I assume you mean that at tokio::spawn, if the user uses essentially tokio::spawn(future.instrument(span)), that span's user-set values would be worth including, which I agree. How would we detect that? I at first thought since F: 'static, we could check the TypeId or downcast, but it would be tracing::Instrumented<T>, which would make it a type we couldn't really check for in that way.

I was imagining something a bit simpler, which is that we would just record whatever the first span that's entered inside a spawned task's span is.

from console.

vultix avatar vultix commented on August 15, 2024

As a new console user, I found this behavior to be very surprising. When running this code, I expected that I'd see a task named "fancy_sleep" in tokio-console, with the associated Duration as a field.

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    console_subscriber::init();

    tokio::task::spawn(fancy_sleep(Duration::from_secs(30))).await?;
    Ok(())
}

#[instrument]
async fn fancy_sleep(duration: Duration) {
    tokio::time::sleep(duration).await;
}

I've looked for workarounds, but nothing feels especially satisfying to me. I could use task::Builder, but it seems needlessly verbose, duplicates the function name, and doesn't capture the instrumented duration field.

    task::Builder::new()
        .name("fancy_sleep")
        .spawn(fancy_sleep(Duration::from_secs(30)))?
        .await?;

from console.

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.