/** * Builds the metrics that can be sent to Application master. * Note that some of the metrics are computed in the cassandra driver itself and hence just * extracted from the driver state itself. */ @Override public void endWindow() { super.endWindow(); Timer timerForThisWindow = session.getCluster().getMetrics().getRequestsTimer(); totalWriteRequestsAttempted += timerForThisWindow.getCount(); numberOfHostsWrittenTo = uniqueHostsWrittenToInCurrentWindow.size(); fifteenMinuteWriteRateLatency = timerForThisWindow.getFifteenMinuteRate(); fiveMinuteWriteRateLatency = timerForThisWindow.getFiveMinuteRate(); oneMinuteWriteRateLatency = timerForThisWindow.getOneMinuteRate(); meanWriteRateLatency = timerForThisWindow.getMeanRate(); Metrics.Errors errors = session.getCluster().getMetrics().getErrorMetrics(); totalIgnoresInThisWindow = errors.getIgnores().getCount() - totalIgnoresSinceStart; totalIgnoresSinceStart = errors.getIgnores().getCount(); totalWriteTimeoutsInThisWindow = errors.getWriteTimeouts().getCount() - totalWriteTimeoutsSinceStart; totalWriteTimeoutsSinceStart = errors.getWriteTimeouts().getCount(); totalWriteRetriesInThisWindow = errors.getRetriesOnWriteTimeout().getCount() - totalWriteRetriesSinceStart; totalWriteRetriesSinceStart = errors.getRetriesOnWriteTimeout().getCount(); try { // we do not need any particular state and hence reusing the window id itself windowDataManager.save(currentWindowId,currentWindowId); } catch (IOException e) { LOG.error("Error while persisting the current window state " + currentWindowId + " because " + e.getMessage()); throw new RuntimeException(e.getMessage()); } }
public void registerAll() { Metrics driverMetrics = session.getCluster().getMetrics(); registerLoadMetrics(driverMetrics); registerErrorMetrics(driverMetrics); registerPerHostMetrics(); }
private void registerLoadMetrics(Metrics driverMetrics) { metricsRegistry.register("Requests", SCOPE, LOAD_TYPE, driverMetrics.getRequestsTimer()); metricsRegistry.register("KnownHosts", SCOPE, LOAD_TYPE, driverMetrics.getKnownHosts()); metricsRegistry.register("ConnectedToHosts", SCOPE, LOAD_TYPE, driverMetrics.getConnectedToHosts()); metricsRegistry.register("OpenConnections", SCOPE, LOAD_TYPE, driverMetrics.getOpenConnections()); metricsRegistry.register("TrashedConnections", SCOPE, LOAD_TYPE, driverMetrics.getTrashedConnections()); metricsRegistry.register("ExecutorQueueDepth", SCOPE, LOAD_TYPE, driverMetrics.getExecutorQueueDepth()); metricsRegistry.register("BlockingExecutorQueueDepth", SCOPE, LOAD_TYPE, driverMetrics.getBlockingExecutorQueueDepth()); metricsRegistry.register("ReconnectionSchedulerQueueSize", SCOPE, LOAD_TYPE, driverMetrics.getReconnectionSchedulerQueueSize()); metricsRegistry.register("TaskSchedulerQueueSize", SCOPE, LOAD_TYPE, driverMetrics.getTaskSchedulerQueueSize()); }
/** * Registers metrics for this cluster. Ideally this would be done before the cluster is started so conflicting * metric names could be detected earlier, but since the CQL driver doesn't publish metrics until after it is * initialized the metrics cannot be registered until then. */ private void registerMetrics() { if (_metricName == null) { // No metric name was provided; skip registration return; } Metrics metrics = _cluster.getMetrics(); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "connected-to-hosts"), metrics.getConnectedToHosts()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "open-connections"), metrics.getOpenConnections()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "trashed-connections"), metrics.getTrashedConnections()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "executor-queue-depth"), metrics.getExecutorQueueDepth()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "blocking-executor-queue-depth"), metrics.getBlockingExecutorQueueDepth()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "reconnection-scheduler-task-count"), metrics.getReconnectionSchedulerQueueSize()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "task-scheduler-task-count"), metrics.getTaskSchedulerQueueSize()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "connection-errors"), metrics.getErrorMetrics().getConnectionErrors()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "read-timeouts"), metrics.getErrorMetrics().getReadTimeouts()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "write-timeouts"), metrics.getErrorMetrics().getWriteTimeouts()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "client-timeouts"), metrics.getErrorMetrics().getClientTimeouts()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "ignores"), metrics.getErrorMetrics().getIgnores()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "unavailables"), metrics.getErrorMetrics().getUnavailables()); _metricRegistry.register( MetricRegistry.name("bv.emodb.cql", _metricName, "ConnectionPool", "speculative-executions"), metrics.getErrorMetrics().getSpeculativeExecutions()); }
private void registerErrorMetrics(Metrics driverMetrics) { metricsRegistry.register("ConnectionErrors", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getConnectionErrors()); metricsRegistry.register("AuthenticationErrors", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getAuthenticationErrors()); metricsRegistry.register("WriteTimeouts", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getWriteTimeouts()); metricsRegistry.register("ReadTimeouts", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getReadTimeouts()); metricsRegistry.register("Unavailables", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getUnavailables()); metricsRegistry.register("ClientTimeouts", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getClientTimeouts()); metricsRegistry.register("OtherErrors", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getOthers()); metricsRegistry.register("Retries", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getRetries()); metricsRegistry.register("RetriesOnReadTimeout", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getRetriesOnReadTimeout()); metricsRegistry.register("RetriesOnWriteTimeout", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getRetriesOnWriteTimeout()); metricsRegistry.register("RetriesOnUnavailable", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getRetriesOnUnavailable()); metricsRegistry.register("RetriesOnClientTimeout", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getRetriesOnReadTimeout()); metricsRegistry.register("RetriesOnConnectionError", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getRetriesOnConnectionError()); metricsRegistry.register("RetriesOnOtherErrors", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getRetriesOnOtherErrors()); metricsRegistry.register("Ignores", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getIgnores()); metricsRegistry.register("IgnoresOnReadTimeout", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getIgnoresOnReadTimeout()); metricsRegistry.register("IgnoresOnWriteTimeout", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getIgnoresOnWriteTimeout()); metricsRegistry.register("IgnoresOnUnavailable", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getIgnoresOnUnavailable()); metricsRegistry.register("IgnoresOnClientTimeout", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getIgnoresOnClientTimeout()); metricsRegistry.register("IgnoresOnConnectionErrors", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getIgnoresOnConnectionError()); metricsRegistry.register("IgnoresOnOtherErrors", SCOPE, ERROR_TYPE, driverMetrics.getErrorMetrics().getIgnoresOnOtherErrors()); }