I'm trying to measure the server side query execution time for a query in Cassandra using the java driver. I'm using rSet.getExecutionInfo().getQueryTrace().getDurationMicros() where rSet is the result set for the query I'm executing. I manually turned on tracing using cqlsh and was able to get the trace through cqlsh but I get a null value when I try it with the java driver. Is there something else I should be doing to enable tracing while using the java driver?
EDIT
Adding code used to query and connect to the cluster.
The code snippet I use to query and measure server side execution time
ResultSet rSet = session.execute("SELECT * from quelea.users where user_id = " + userId +" ALLOW Filtering");
System.out.println("Server-side query Execution time : " + rSet.getExecutionInfo().getQueryTrace()).getDurationMicros());
The code I use to connect to the Cassandra cluster
public void connect(final String node, final int port)
{
this.cluster = Cluster.builder().addContactPoint(node).withPort(port).build();
final Metadata metadata = cluster.getMetadata();
out.printf("Connected to cluster: %s\n", metadata.getClusterName());
for (final Host host : metadata.getAllHosts())
{
out.printf("Datacenter: %s; Host: %s; Rack: %s\n",
host.getDatacenter(), host.getAddress(), host.getRack());
}
session = cluster.connect();
}
getQueryTrace() returns the QueryTrace object for this query if tracing was enable for this query, or null otherwise.could this be the reason you get a NPE? - fill͡pant͡