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
Level filtering is broken when depending on tracing-subscriber from crates.io #2927
Comments
Can you replicate this if you set a dependency on (I'm guessing is this in Zed: is it zed-industries/zed#10085?) |
Related: tokio-rs/tracing#2927 Co-Authored-By: Nathan <nathan@zed.dev>
That does not seem to fix the problem, so I guess the difference is in the commits between 0.1.32 and the tracing-subscriber release. You can test here: zed-industries/zed@d56730b vs zed-industries/zed@d1c6b4a By running:
(Though you'll need to set up the local collaboration dev dependencies: https://zed.dev/docs/local-collaboration) |
Well, this is extremely strange; the Can you run |
On the version I've marked as broken, the output is here: https://gist.github.com/ConradIrwin/dc0103d52e390eae9ebacc87c311cdb4. On the commit I've tagged as working, I get:
So I guess both are being included, but as there are commits in the git repo's tracing-core directory at tag tracing-subscriber-0.3.18 that are not released by tracing-core-0.1.32 this is not actually running the same code as the released crate. I haven't yet tried bisecting these commits, but a quick scan of the messages reveals no obvious culprits. It's also worth noting that the tracing-subscriber v0.3.18 depends on tracing-core This could also be a bug in any of the other tracing-* crates; because they are all released on different schedules, the versions on crates.io will rarely correspond to a state of the git repository that ever existed. In terms of narrowing the bug down:
|
Looking into this more, it seems like there's some kind of unexpected interaction with sqlx. I suspect that the reason it "works" when we include the git version is because sqlx is still depending on the non-git version and so shared state is not mutated. From the broken commit on zed above, I narrowed down the test case, and it seems that if I don't make any SQL queries between init'ing the tracing subscriber and logging, then the log levels are preserved. I also observe that I can control logging of collab::rpc's error logs by changing the filter on the sqlx package:
It also seems that if I build zed's collab using sqlite instead of Postgres, that fixes the problem. |
Ok, zooming in more; the problem is this call in the sqlx-postgres crate: https://github.com/launchbadge/sqlx/blob/635dba5b2682033101a1271e9fb4bf2516c0b840/sqlx-postgres/src/connection/stream.rs#L154-L156 A minimal reproduction of this bug is ConradIrwin/tracing-bug@00a1b14#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fc |
Oh, thank you for the minimal reproduction—that is a bit odd. I bet we're doing something silly when interacting with |
Although we thought this fixed the bug, it just worked around it, and runnign two copies of tracing in one app is a bad idea. Simplify default RUST_LOG in development to avoid tokio-rs/tracing#2927 (comment)
Although we thought this fixed the bug, it just worked around it, and runnign two copies of tracing in one app is a bad idea. Simplify default RUST_LOG in development to avoid tokio-rs/tracing#2927 (comment) Release Notes: - N/A
Bug Report
Version
mixed
Platform
macOS
Description
Depend on
tracing-subscriber = { version = 0.3.18, features = ["env-filter", "json", "registry", "tracing-log"] }
from crates.ioSet an env filter to a string like
warn,collab::rpc=info
Notice that output from
tracing::error!
insidecollab::rpc
with level ERROR is not printed to the console.Replace
tracing-subscriber = { git = "https://github.com/tokio-rs/tracing", rev = "tracing-subscriber-0.3.18", features = ["env-filter", "json", "registry", "tracing-log"] }
Notice that output from
tracing::error!
insidecollab::rpc
with level ERROR is printed to the consoleWe dug into this a little bit and noticed that the published version of
tracing-subscriber
depends ontracing-core
v0.1.30 but when we depend on the git repository directly we get a version of tracing-core that's just a bit newer thanv0.1.32
. It seems to be the case that when the versions mismatch like this the filtering logic is sometimes wrong.The text was updated successfully, but these errors were encountered: