public class Metrics extends Object
Modifier and Type | Class and Description |
---|---|
class |
Metrics.Errors
Metrics on errors encountered.
|
Modifier and Type | Method and Description |
---|---|
com.codahale.metrics.Gauge<Integer> |
getBlockingExecutorQueueDepth()
Returns the number of queued up tasks in the
blocking executor . |
com.codahale.metrics.Gauge<Integer> |
getConnectedToHosts()
Returns the number of Cassandra hosts the driver is currently connected to
(that is have at least one connection opened to).
|
Metrics.Errors |
getErrorMetrics()
Returns an object grouping metrics related to the errors encountered.
|
com.codahale.metrics.Gauge<Integer> |
getExecutorQueueDepth()
Returns the number of queued up tasks in the
main internal executor . |
com.codahale.metrics.Gauge<Integer> |
getInFlightRequests()
Returns the total number of in flight requests to Cassandra hosts.
|
com.codahale.metrics.Gauge<Integer> |
getKnownHosts()
Returns the number of Cassandra hosts currently known by the driver (that is
whether they are currently considered up or down).
|
com.codahale.metrics.Gauge<Integer> |
getOpenConnections()
Returns the total number of currently opened connections to Cassandra hosts.
|
com.codahale.metrics.Gauge<Integer> |
getReconnectionSchedulerQueueSize()
Returns the number of queued up tasks in the
reconnection executor . |
com.codahale.metrics.MetricRegistry |
getRegistry()
Returns the registry containing all metrics.
|
com.codahale.metrics.Timer |
getRequestsTimer()
Returns metrics on the user requests performed on the Cluster.
|
com.codahale.metrics.Gauge<Integer> |
getTaskSchedulerQueueSize()
Returns the number of queued up tasks in the
scheduled tasks executor . |
com.codahale.metrics.Gauge<Integer> |
getTrashedConnections()
Returns the total number of currently "trashed" connections to Cassandra hosts.
|
public com.codahale.metrics.MetricRegistry getRegistry()
metrics
is this
object, you could export the
metrics to csv files using:
com.codahale.metrics.CsvReporter.forRegistry(metrics.getRegistry()).build(new File("measurements/")).start(1, TimeUnit.SECONDS);If you already have a
MetricRegistry
in your application and wish to
add the driver's metrics to it, the recommended approach is to use a listener:
// Your existing registry: final com.codahale.metrics.MetricRegistry myRegistry = ... cluster.getMetrics().getRegistry().addListener(new com.codahale.metrics.MetricRegistryListener() { @Override public void onGaugeAdded(String name, Gauge<?> gauge) { if (myRegistry.getNames().contains(name)) { // name is already taken, maybe prefix with a namespace ... } else { myRegistry.register(name, gauge); } } ... // Implement other methods in a similar fashion });Since reporting is handled by your registry, you'll probably also want to disable JMX reporting with
Cluster.Builder.withoutJMXReporting()
.public com.codahale.metrics.Timer getRequestsTimer()
Timer
metric object exposing the rate and latency for
user requests.public Metrics.Errors getErrorMetrics()
public com.codahale.metrics.Gauge<Integer> getKnownHosts()
public com.codahale.metrics.Gauge<Integer> getConnectedToHosts()
public com.codahale.metrics.Gauge<Integer> getOpenConnections()
public com.codahale.metrics.Gauge<Integer> getTrashedConnections()
PoolingOptions.getIdleTimeoutSeconds()
), in case the load
goes up again. This metric counts connections in that state.public com.codahale.metrics.Gauge<Integer> getInFlightRequests()
public com.codahale.metrics.Gauge<Integer> getExecutorQueueDepth()
main internal executor
.
If the executor's task queue is not accessible – which happens when the executor
is not an instance of ThreadPoolExecutor
– then this gauge returns -1.public com.codahale.metrics.Gauge<Integer> getBlockingExecutorQueueDepth()
blocking executor
.
If the executor's task queue is not accessible – which happens when the executor
is not an instance of ThreadPoolExecutor
– then this gauge returns -1.public com.codahale.metrics.Gauge<Integer> getReconnectionSchedulerQueueSize()
reconnection executor
.
A queue size > 0 does not
necessarily indicate a backlog as some tasks may not have been scheduled to execute yet.
If the executor's task queue is not accessible – which happens when the executor
is not an instance of ThreadPoolExecutor
– then this gauge returns -1.public com.codahale.metrics.Gauge<Integer> getTaskSchedulerQueueSize()
scheduled tasks executor
.
A queue size > 0 does not
necessarily indicate a backlog as some tasks may not have been scheduled to execute yet.
If the executor's task queue is not accessible – which happens when the executor
is not an instance of ThreadPoolExecutor
– then this gauge returns -1.Copyright © 2012–2018. All rights reserved.