-
Notifications
You must be signed in to change notification settings - Fork 110
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
Remove .with_current_subscriber()
calls
#992
Remove .with_current_subscriber()
calls
#992
Conversation
|
I'm not entirely sure. I might have discussed the original problem long ago with Gor and/or @wprzytula. I think it might have been necessary for the cpp-rust-wrapper. One use case that comes to my mind is:
|
Might be related to this: scylladb/cpp-rust-driver#110 |
Indeed, this cpp-rust-driver's logging might malfunction after those calls are removed. @Lorak-mmk please build the cpp-rust-driver against custom rust driver with those calls removed and check that logging still works. |
If I understand correctly this is not in issue when global default subscriber is used, because it is a default for all threads. This is what cpp-rust-driver currently does. |
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.
Cargo.lock.msrv
needs to be updated. Otherwise, looks acceptable to me, although I'm still reluctant to believe that cpp-rust-driver's logging really works without those calls; they really had some purpose and I feel that there is some trap that we forget about.
If there is something that I didn't notice I'd prefer to work around it in cpp-rust-driver (even if it's inconvenient or even requires a patched version of the driver) rather than break the experience for Rust Driver users. |
20c8002
to
dd457c7
Compare
Those calls were introduced in e557095, with message: ``` Now, when the driver spawns a task to run a new future on it, that future will use the same subscriber as the code that spawned the task in the first place. ``` There is unfortunately no explanation about when it is necessary. I don't see any problems after removing those - logs are still collected correctly using a tracing subscriber. Those calls however have a harmful side-effect: they prevent usage of `log` loggers to listen to driver logs using `log` feature in `tracing` crate. After reporting the problem to `tracing` crate: tokio-rs/tracing#2913 one of maintainers said that using `.with_current_subscriber()` in a library is not necessary in general. As I don't see any issue caused by removing these calls, but their existence cause an issue, they are removed in this commit.
This example demonstrates usage of `env_logger` to listen to driver logs.
dd457c7
to
2199bda
Compare
2199bda
to
370b00a
Compare
You can use `cargo add tracing -F log` or edit `Cargo.toml`: | ||
```toml | ||
tracing = { version = "0.1.40" , features = ["log"] } | ||
``` | ||
then you can setup `env_logger` os some other logger and it will output logs from the driver: |
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.
Will enabling log
feature in the end crate's Cargo.toml suffice, or is it required to have it enabled for scylla crate as well?
Another question. What if the end user crate uses tracing
crate in version that is incompatible with the version that scylla
crate uses?
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.
- Yes, it is enough
- Not sure what you are asking. Are you asking if adding hypotetical tracing 0.2 to end user Cargo.toml and enabling log feature there will enable log feature in our tracing 0.1? No, it won't
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.
Quoting comment from the tracing issue I opened (tokio-rs/tracing#2913 (comment) ):
A library should not generally enable the log or log-always feature flags, and generally should never be responsible for setting the default subscriber. Instead, user code that depends on the library should enable tracing's log crate support if it wants to, and set the default subscriber if it wishes to use tracing. I don't think the calls to with_current_subscriber are necessary in a library in general.
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.
- I'm asking about whether mismatched versions of
tracing
inscylla
crate and the end crate can cause incompatility issues, resulting in misbehaving tracing.
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.
No idea, probably. It's a question to tracing crate maintainers, how are they going to handle new major version to avoid ecosystem split.
…bscriber Remove `.with_current_subscriber()` calls (cherry picked from commit 88bc8c1)
…bscriber Remove `.with_current_subscriber()` calls (cherry picked from commit 88bc8c1)
Those calls were introduced in e557095,
with message:
There is unfortunately no explanation about when it is necessary.
I don't see any problems after removing those - logs are still collected correctly using a tracing subscriber.
Those calls however have a harmful side-effect: they prevent usage of
log
loggers to listen to driver logs usinglog
feature intracing
crate, which was reported in #860 .After reporting the problem to
tracing
crate (tokio-rs/tracing#2913) one of maintainers said that using.with_current_subscriber()
in a library is not necessary in general.As I don't see any issue caused by removing these calls, but their existence cause an issue, they are removed in this PR.
The PR also introduces an example showing usage of the driver with
env_logger
and adjusts documentation about logging.Fixes: #860
@piodul if you remember why those calls were added please explain, because I have no idea in which scenario they could be necessary.
Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.