scylladb / scylla-rust-driver

Async CQL driver for Rust, optimized for ScyllaDB!
Apache License 2.0
582 stars 101 forks source link

Warnings from queries should be logged (unless such a mechanism is explicitly disabled) #265

Open psarna opened 3 years ago

psarna commented 3 years ago

Ref: https://github.com/scylladb/scylla/issues/9001#issuecomment-878073435

Responses from correct CQL queries should generally not contain any warnings. If they do, it usually means that the user is doing something wrong and should be notified about it. Our driver already uses the tracing crate for logs, so this mechanism should also be used to propagate warnings from CQL responses, if any are found.

In order to be able to avoid spam in certain cases (e.g. a large number of queries is expected to cause warnings, but they need to be executed anyway), this mechanism should have a safety valve, which allows disabling the propagation.

piodul commented 3 years ago

We already print warnings with tracing (although unconditionally, without a way to disable it):

https://github.com/scylladb/scylla-rust-driver/blob/efb170182f5d1e0b0a467077c627513a7ee47d40/scylla/src/transport/connection.rs#L534-L536

It seems that there are some mechanisms to filter events provided by the tracing ecosystem (I see something here), however I'm not very familiar with tracing so I cannot tell if and how it would fit in this case - more investigation is needed.

It's also worth mentioning that it's up to the user to correctly set up tracing so that it prints messages or does something useful (fortunately, it's easy, e.g. like this).

wprzytula commented 6 months ago

We already print warnings with tracing (although unconditionally, without a way to disable it).

I think we can close this then. WDYT @Lorak-mmk?

wprzytula commented 5 months ago

Ping @Lorak-mmk

Lorak-mmk commented 5 months ago

Printing trough tracing is enough, but the issue also suggests a mechanism to disable it. We should either implement it or verify that such filtering is possible and ergonomic using mechanisms provided by tracing ecosystem.