-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
util: Make tracing optional when codec is enabled #6434
Conversation
Signed-off-by: Jens Reidel <adrian@travitia.xyz>
Signed-off-by: Jens Reidel <adrian@travitia.xyz>
This seems reasonable to me, but I have two questions.
|
I think making the However, I do want to offer an alternative solution, which would also benefit This way, we remove the |
tokio-util already has disabled the attribute, and tokio-websockets does too. I think there is a crate somewhere in tokio-websockets's dependency tree that has the attribute enabled, but I'm not sure how easy it is to find it. Line 45 in 9c337ca
|
Good catch! I found the issue: hyper-util depends on tower > 0.4.0, which will use tracing with default features... See tower-rs/tower@7f004da That is an easy fix since I wanted to rip out the hyper specific stuff anyways, but I think that this PR has some added value nonetheless. Consumers of this crate that either don't need tracing or don't want trace logs from this library (very likely) won't need the tracing dependency in this crate. EDIT: I don't get it...
Seems like tokio-util is the only thing depending on tracing, and tracing-attributes are pulled in. EDIT 2: tokio-util 0.7.3 is the first without default features on tracing, that should fix it. |
I guess it's probably fine to disable the feature by default. |
I'm fine with disabling the feature by default, as I agree most users probably don't consume these traces. |
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.
Motivation
I maintain a library that implements the websocket protocol using tokio-util's
FramedRead
for decoding frames. I conduct testing usingcargo-minvers
in CI to ensure that my minimum dependency versions are correct and working as they are intended to.proc-macro2 is a crate that very, very often breaks with newer rustc versions (most recently, a rustc update broke versions prior to 1.0.60, see this issue). tracing-attributes depends on proc-macro2 and regularly has to bump the minimum version to fix their own
cargo-minvers
checks (see this commit bumping the dependency).My issue lies exactly here. tokio-util's codec module depends on tracing, which in turn breaks my minvers check every once in a while due to the tracing version required by tokio-util being too low with the recent rustc I run my checks with. Of course bumping the dependency in tokio-util makes little sense, so my current "fix" is to pin the minimum version of tracing in my crate myself (like so).
But that is just tedious and seems wrong for a dependency that is only used for
trace!
macro calls. A lot of headaches and needless CI failures could just be fixed by not depending ontracing
.Solution
This PR makes the tracing usage in the codec module optional, allowing people to opt-in to the events or out of the regular minvers breakage.