Skip to content

runtime: Instrument with tracing#6981

Merged
AdamGS merged 1 commit intovortex-data:developfrom
polarsignals:tracing
Mar 16, 2026
Merged

runtime: Instrument with tracing#6981
AdamGS merged 1 commit intovortex-data:developfrom
polarsignals:tracing

Conversation

@brancz
Copy link
Contributor

@brancz brancz commented Mar 16, 2026

Summary

This is so that tracing subscribers, can correctly attribute information to eg. opentelemetry distributed tracing IDs.

API Changes

None

Testing

Wrote a test, but didn't check it in because it would require the std feature of tracing and make tracing-subscriber a dependency. Happy to add the test if those things are ok.

    #[tokio::test]
    async fn test_spawn_propagates_tracing_span() {
        install_global_subscriber();
        let handle = TokioRuntime::current();

        let span = tracing::info_span!("parent_span");
        let parent_id = span.id();
        assert!(parent_id.is_some(), "subscriber must be active");
        let _enter = span.enter();

        // spawn: async future is instrumented with the parent span
        let spawned_id = handle.spawn(async { tracing::Span::current().id() }).await;
        assert_eq!(spawned_id, parent_id, "spawn should propagate span");

        // spawn_cpu: closure enters the parent span
        let cpu_id = handle.spawn_cpu(|| tracing::Span::current().id()).await;
        assert_eq!(cpu_id, parent_id, "spawn_cpu should propagate span");

        // spawn_blocking: closure enters the parent span on the blocking thread
        let blocking_id = handle
            .spawn_blocking(|| tracing::Span::current().id())
            .await;
        assert_eq!(
            blocking_id, parent_id,
            "spawn_blocking should propagate span"
        );
    }

This is so that tracing subscribers, can correctly attribute information
to eg. opentelemetry distributed tracing IDs.

Signed-off-by: Frederic Branczyk <fbranczyk@gmail.com>
@AdamGS AdamGS added the changelog/chore A trivial change label Mar 16, 2026
@AdamGS
Copy link
Contributor

AdamGS commented Mar 16, 2026

I'm not sure there's a test that will make me super confident that tracing is correctly set up in async rust 😅 code is simple enough and seems correct to me.

@AdamGS AdamGS enabled auto-merge (squash) March 16, 2026 15:18
@AdamGS AdamGS merged commit c58d993 into vortex-data:develop Mar 16, 2026
60 of 61 checks passed
@brancz brancz deleted the tracing branch March 16, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/chore A trivial change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants