Skip to content

Conversation

@mdup
Copy link

@mdup mdup commented Sep 8, 2025

Before this PR, tracing logs work with the default subscriber (which is the usual case), but when one sets a custom tracing subscriber, it isn't passed across tokio::spawn boundaries.

In this PR I'm adding the method .with_current_subscriber() to server tasks. This allows the logging subscriber to be carried into the spawned tasks.

// Before: subscriber context lost
tokio::spawn(async { ... });

// After: subscriber context preserved  
tokio::spawn(async { ... }.with_current_subscriber());

My use case is capturing logging for integration tests, for which I need to set a custom tracing subscriber. I think this PR shouldn't change anything in the common case of a global subscriber.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant