wederbrand avatar image
wederbrand asked wederbrand commented

Where is the consistency level logging in Java driver version 4.6.1?

In older versions of the driver, 3.6.0 as an example, it was possible to turn on trace logging on the class com.datastax.driver.core.Connection and get information on what consistency level was used.

I find no such logging in 4.6.1. The built in RequestLogger doesn't seem to log consistency level at all. Can I find it in any other way than through wireshark?

I know that cassandra 3.11 adds some of this but I'm not on 3.11 yet.


java driverconsistency levellogging
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

alexandre.dutra avatar image
alexandre.dutra answered

There is no simple way I'm afraid, but you shouldn't need to resort to wireshark either.

Driver 3.x Connection class is logging the raw protocol objects. The equivalent objects in driver 4.x are actually externalized in a library named native-protocol. The toString() method of various objects in this library (e.g. the Query.toString() method) do not print the consistency level, so we would have to change that. (If you want to provide a PR for that, that would be welcome.) – Once this is done, we could add somme trace logging somewhere in the driver, e.g. in com.datastax.oss.driver.internal.core.cql.Conversions.

Another, possibly much simpler solution would be to print the consistency level of high-level objects like Statement. It is true that RequestLogger does not do that, but it should be fairly simple to extend that class, or copy-paste it, and modify it to your needs. Feel free to open a Jira ticket for that, or if you can, simply provide a PR and I will gladly review it.

10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Erick Ramirez avatar image
Erick Ramirez answered wederbrand commented

This isn't a direct answer to your post but it seems strange to me why you'd need to trace the consistency level used by your app and even resort to using Wireshark.

The way I look at it, a developer would configure the consistency level using execution profiles in version 4 of the Java driver. I'd be very surprised if your developers were configuring the consistency on a per-query basis.

And if you were setting the consistency using the recommended execution profiles, it doesn't make sense that you would need trace logging to determine what consistency level was used -- because you should already know it. :)

Perhaps if you tell us what problem you're trying to solve, we might be in a position to give you a more appropriate solution. Cheers!

1 comment Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

wederbrand avatar image wederbrand commented ·

I have a mix of Spring Crud Repositories, Spring CQLTemplate and Datastax Prepared statements with binds and reading the logs with 3.6.0 was a great way of observing the Consistency Level used.

Especially since it's possible, in my environment, to reconfigure some of them using environment variables as overrides.

That in turn is needed since some of the cassandra clusters (for different environments) have a different replication factor so the values for concistency level can't always be hard coded.

But the answers from you and @alexandre.dutra are sufficient, I'll have to manage.


0 Likes 0 ·