Package com.datastax.driver.core
Class QueryLogger.DynamicThresholdQueryLogger
- java.lang.Object
-
- com.datastax.driver.core.QueryLogger
-
- com.datastax.driver.core.QueryLogger.DynamicThresholdQueryLogger
-
- All Implemented Interfaces:
LatencyTracker
- Enclosing class:
- QueryLogger
public static class QueryLogger.DynamicThresholdQueryLogger extends QueryLogger
A QueryLogger that uses a dynamic threshold in milliseconds to track slow queries.Dynamic thresholds are based on per-host latency percentiles, as computed by
PercentileTracker.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.datastax.driver.core.QueryLogger
QueryLogger.Builder, QueryLogger.ConstantThresholdQueryLogger, QueryLogger.DynamicThresholdQueryLogger
-
-
Field Summary
-
Fields inherited from class com.datastax.driver.core.QueryLogger
cluster, DEFAULT_MAX_LOGGED_PARAMETERS, DEFAULT_MAX_PARAMETER_VALUE_LENGTH, DEFAULT_MAX_QUERY_STRING_LENGTH, DEFAULT_SLOW_QUERY_THRESHOLD_MS, DEFAULT_SLOW_QUERY_THRESHOLD_PERCENTILE, ERROR_LOGGER, maxLoggedParameters, maxParameterValueLength, maxQueryStringLength, NORMAL_LOGGER, SLOW_LOGGER
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PercentileTrackergetPercentileLatencyTracker()Return the percentile tracker to use for recording per-host latency histograms.doublegetSlowQueryLatencyThresholdPercentile()Return the threshold percentile beyond which queries are considered 'slow' and logged as such by the driver.protected voidmaybeLogNormalOrSlowQuery(Host host, Statement statement, long latencyMs)protected voidmaybeLogSlowQuery(Host host, Statement statement, long latencyMs, long threshold)voidonRegister(Cluster cluster)Gets invoked when the tracker is registered with a cluster, or at cluster startup if the tracker was registered at initialization withCluster.register(LatencyTracker).voidsetPercentileLatencyTracker(PercentileTracker percentileLatencyTracker)Set the percentile tracker to use for recording per-host latency histograms.voidsetSlowQueryLatencyThresholdPercentile(double slowQueryLatencyThresholdPercentile)Set the threshold percentile beyond which queries are considered 'slow' and logged as such by the driver.-
Methods inherited from class com.datastax.driver.core.QueryLogger
append, append, appendParameters, appendParameters, appendParameters, builder, countBoundValues, getMaxLoggedParameters, getMaxParameterValueLength, getMaxQueryStringLength, logQuery, maybeLogErrorQuery, maybeLogNormalQuery, onUnregister, parameterValueAsString, parameterValueAsString, setMaxLoggedParameters, setMaxParameterValueLength, setMaxQueryStringLength, statementAsString, update
-
-
-
-
Method Detail
-
getPercentileLatencyTracker
public PercentileTracker getPercentileLatencyTracker()
Return the percentile tracker to use for recording per-host latency histograms. Cannot benull.- Returns:
- the percentile tracker to use.
-
setPercentileLatencyTracker
public void setPercentileLatencyTracker(PercentileTracker percentileLatencyTracker)
Set the percentile tracker to use for recording per-host latency histograms. Cannot benull.- Parameters:
percentileLatencyTracker- the percentile tracker instance to use.- Throws:
IllegalArgumentException- ifpercentileLatencyTracker == null.
-
getSlowQueryLatencyThresholdPercentile
public double getSlowQueryLatencyThresholdPercentile()
Return the threshold percentile beyond which queries are considered 'slow' and logged as such by the driver. The default value isQueryLogger.DEFAULT_SLOW_QUERY_THRESHOLD_PERCENTILE.- Returns:
- threshold percentile beyond which queries are considered 'slow' and logged as such by the driver.
-
setSlowQueryLatencyThresholdPercentile
public void setSlowQueryLatencyThresholdPercentile(double slowQueryLatencyThresholdPercentile)
Set the threshold percentile beyond which queries are considered 'slow' and logged as such by the driver.- Parameters:
slowQueryLatencyThresholdPercentile- Slow queries threshold percentile. It must be comprised between 0 inclusive and 100 exclusive.- Throws:
IllegalArgumentException- ifslowQueryLatencyThresholdPercentile < 0 || slowQueryLatencyThresholdPercentile >= 100.
-
maybeLogNormalOrSlowQuery
protected void maybeLogNormalOrSlowQuery(Host host, Statement statement, long latencyMs)
- Specified by:
maybeLogNormalOrSlowQueryin classQueryLogger
-
maybeLogSlowQuery
protected void maybeLogSlowQuery(Host host, Statement statement, long latencyMs, long threshold)
-
onRegister
public void onRegister(Cluster cluster)
Description copied from interface:LatencyTrackerGets invoked when the tracker is registered with a cluster, or at cluster startup if the tracker was registered at initialization withCluster.register(LatencyTracker).- Specified by:
onRegisterin interfaceLatencyTracker- Overrides:
onRegisterin classQueryLogger- Parameters:
cluster- the cluster that this tracker is registered with.
-
-