-
Notifications
You must be signed in to change notification settings - Fork 94
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
scylla: Enable log
feature in tracing
#915
Conversation
This allows applications using `log` ecosystem to receive logs from the driver. There shouldn't be a significant performance penalty, because `log` events are emitted only if there is not `Subscriber` active.
@@ -38,7 +38,7 @@ thiserror = "1.0" | |||
itertools = "0.11.0" | |||
bigdecimal = "0.2.0" | |||
num-bigint = "0.3" | |||
tracing = "0.1.36" | |||
tracing = { version = "0.1.36", features = ["log"] } |
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 think it is wrong for us to unconditionally enable this feature. Our crate does not need it at all in order to function properly. The decision whether to enable the feature or not should be on the application developers (as it controls global behavior) - they can explicitly depend on tracing
in their application and enable log
feature.
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 not very familiar with how Cargo handles dependencies, resolves versions etc. I know it's possible to have 2 copies (2 versions) of the same dependency. What is user supposed to do if they want to enable log
feature in tracing
used by our driver and not include another tracing
copy?
Is it possible for us to have a feature that enables log
feature in tracing
? I feel like this would be a bit easier to use.
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 not very familiar with how Cargo handles dependencies, resolves versions etc. I know it's possible to have 2 copies (2 versions) of the same dependency. What is user supposed to do if they want to enable
log
feature intracing
used by our driver and not include anothertracing
copy?
They need to specify a version constraint such that the cargo resolver will choose the same version. I don't know all the intricacies of the algorithm either, but I'm pretty sure that if you specify:
[dependencies]
tracing = { version = "0.1", features = ["log"] }
then, given that we have tracing = "0.1.36"
in our depencencies, the resolver will choose the same version and instance of the tracing
crate. Users can verify if they succeeded by looking at Cargo.lock
.
Is it possible for us to have a feature that enables
log
feature intracing
? I feel like this would be a bit easier to use.
Yes, it is possible. However, I still think it's weird for us to add such a feature. If we were to add it, going further with that logic, all other library crates that use tracing
internally should have such a feature as well - this does not scale. Users can easily enable the necessary feature in tracing
for their application with the method I outlined.
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 not very familiar with how Cargo handles dependencies
I think it uses the crate with the most features enabled. Just a guess, because sometimes after removing a crate which enabled some features (for tokio
for example), it required me to enable these features (for tokio
) manually.
So if you require tracing
with log
manually (separately from scylla
), it might use it.
I looked at how is this feature implemented. See the following links: So basically it looks like the cost is one atomic relaxed load per log call. Considering that this atomic is only written to at most once iiuc the value should be cached and there should be no contention / other problems, so overhead should be negligible. After reading https://docs.rs/tracing/latest/tracing/#emitting-log-records and source code I think this could be in our default features - this will allow both apps using |
It does not help actually. I will provide you with an example a bit later. |
I'll respond in the issue, so that discussion is there and not in a PR |
Turns out that most likely the original issue is not the fault of Scylla. I think adding the |
Turns out enabling log integration is not that easy as just enabling |
This allows applications using
log
ecosystem to receive logs from the driver.There shouldn't be a significant performance penalty, because
log
events are emitted only if there is notSubscriber
active.TODO:
log
is bugged, buttracing
works #860 - needs verificationPre-review checklist
./docs/source/
.Fixes:
annotations to PR description.