Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task: make task span explicit root #6158

Merged
merged 2 commits into from Nov 19, 2023
Merged

task: make task span explicit root #6158

merged 2 commits into from Nov 19, 2023

Commits on Nov 18, 2023

  1. task: make task span explicit root

    In Tokio, tasks are optionally instrumented with tracing spans to allow
    analysis of the runtime behavior to be performed with tools like
    tokio-console.
    
    The span that is created for each task gets currently follows the
    default tracing behavior and has a contextual parent attached to it
    based on the span that is actual when `tokio::spawn` or similar is
    called.
    
    However, in tracing, a span will remain "alive" until all its children
    spans are closed. This doesn't match how spawned tasks work. A task may
    outlive the context in which is was spawned (and frequently does). This
    causes tasks which spawn other - longer living - tasks to appear in
    `tokio-console` as having lost their waker when instead they should be
    shown as completed (tokio-rs/console#345). It can also cause undesired
    behavior for unrelated tracing spans if a subscriber is receiving both
    the other spans as well as Tokio's instrumentation.
    
    To fix this mismatch in behavior, the task span has `parent: None` set
    on it, making it an explicit root - it has no parent. The same was
    already done for all spans representing resources in #6107. This change
    is made within the scope of #5792.
    
    Due to a defect in the currently available `tracing-mock` crate, it is
    not possible to test this change at a tracing level
    (tokio-rs/tracing#2440). Instead, a test for the `console-subscriber`
    has been written which shows that this change fixes the defect as
    observed in `tokio-console` (tokio-rs/console#490).
    hds committed Nov 18, 2023
    Configuration menu
    Copy the full SHA
    571d01c View commit details
    Browse the repository at this point in the history

Commits on Nov 19, 2023

  1. Configuration menu
    Copy the full SHA
    0243f89 View commit details
    Browse the repository at this point in the history