Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

wederbrand avatar image
wederbrand asked ·

What is the equivalent of LatencyTracker in Java driver 4.6?

With the old driver (3.6.x) I created a profiler that implemented LatencyTracker. I used that to measure execution times against the Cluster (now CqlSession) and exported it using MicroMeter.

With the new driver (4.6.x) there is no LatencyTracker anymore. What is the equivalent? How can I measure query-performance from my application?

Thanks.

java driver
10 |1000 characters needed characters left characters exceeded

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 ·

Have a look at the RequestTracker API. It's a session component that tracks request metadata including latency and outcome.

The request tracker can be enabled via a configuration file or accessed programatically. For example:

datastax-java-driver.advanced.request-tracker {
  class = RequestLogger
 
  logs {
    success.enabled = true
 
    slow {
      threshold = 1 second
      enabled = true
    }
 
    error.enabled = tr
    max-query-length = 500
    show-values = true
    max-value-length = 50
    max-values = 50
    show-stack-traces = true
}

For details, see Request tracker in Java driver 4.6. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

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

smadhavan avatar image
smadhavan answered ·

@wederbrand, the Java driver delivers its internal measurements through the Dropwizard Metrics library. For all versions of the Java Driver, metrics are exposed through a MetricRegistry. The reporter options include JMX, JSON (via a servlet), stdout, CSV files, SLF4J logs, and Graphite. See the Dropwizard Documentation for more details.

Having said that, what you need is to begin here for the 4.x series, https://docs.datastax.com/en/developer/java-driver/4.9/manual/core/metrics/. Additionally, you could also refer to this curated example to get started on how to export Java Driver 4.x metrics over to Prometheus via Prometheus Java Client.

Related Reading:

1 comment Share
10 |1000 characters needed characters left characters exceeded

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

I've been reading up on those but I can't find anyway of measure individual queries using built in metrics.

With LatencyTracker (and with the new RequestTracker) I'm able to build metrics per operations (SELECT, UPDATE, INSERT), keyspace and table.


The built in metrics seems to group all of those into cql-request.

0 Likes 0 ·