O'Reilly logo

Apache Cassandra Essentials by Nitin Padalia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tracing Cassandra queries using Java driver

We discussed tracing in the previous chapter, so you know how we can trace a query using the cqlsh client. Similarly, we can enable tracing on a per-query basis using driver as well. The following code shows a new version of our createStatus() method, with tracing enabled:

public void traceCreateStatus(String userId, String statusMsg) { Statement insertStatement = QueryBuilder .insertInto("apachecassandra", "status_updates_by_user") .value("userid", UUID.fromString(userId)) .value("updated_on", System.currentTimeMillis()) .value("status", statusMsg) .enableTracing(); ResultSet rs = getSession().execute(insertStatement); ExecutionInfo executionInfo = rs.getExecutionInfo(); QueryTrace queryTrace = executionInfo.getQueryTrace(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required