quinn-rs / quinn

Async-friendly QUIC implementation in Rust
Apache License 2.0
3.76k stars 380 forks source link

Preserve the tracing span in the EndpointDriver task #1616

Closed flub closed 1 year ago

flub commented 1 year ago

The EndpointDriver is spawned in a task. Unless the span is copied into this task the current span is lost.

Copying the current span means any tracing calls inside the driver, from e.g. a custom AsyncUdpSocket, are preserved in the span. This makes it easy to use different parent spans for different endpoints and have log messages appear with their parent span. Otherwise these log messages are not attached to a span.


An alternative is to create a new span using tracing::info_span!("endpointdriver") instead of copying the current span. This new span would also be correctly attached to the current span as a child.