-
Notifications
You must be signed in to change notification settings - Fork 124
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
fix(tracing): propagate span context #166
Conversation
The tracing span context set in consumers of the `TokioExecutor` was sometimes lost (if the task was run in a different thread). This adds a call to `in_current_span()` to preserve it.
Interesting, I remember something like this a while ago. I think an issue when doing this automatically is that some tasks that are spawned live longer than the initial context. For example, if a new connection is created when trying to serve a request, and then that connection is put in a pool and used for later requests, the context is no longer the same. |
My understanding is that this isn't a concern for HTTP/2--connection establishment occurs separately from request dispatch; IIUC, the HTTP/1 connection pooling behavior was changed in the 1.0 refactor... what would be the proper way to audit this? Presumably we don't want to look for uses of executor as much as we want to look into HTTP/1 connection reuse? I'm especially interested in making this change so that libraries like kube-rs (cc @clux) can get this behavior without us having to go submit patches to every library that builds a client... |
I'm happy to include something like this. Are you saying that if we made this a wrapping We could alternatively just use |
It would require upstream changes, but I think that would be an acceptable middle-ground (at least we can document the trade offs in the util crate).
I like this approach because it means that applications can control the behavior independently of the underlying libraries; but maybe it makes sense to force library authors to make a choice? I can see both sides of that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, let's do that one: use #[cfg(feature)]
and #[cfg(not(feature))]
blocks inside the function, and don't enable the dependency automatically. I think a tracing
feature will need to be added that would enable it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Hi Sean! 👋
The tracing span context set in consumers of the
TokioExecutor
is sometimes lost (if the task is run in a different thread). This change adds a call toin_current_span()
to preserve it.As a side-effect, it adds a dependency on tracing for the tokio feature. Should I instead allow the new behavior only if tracing is enabled? Or use a separate
TracingExecutor
for this?