Package com.datastax.driver.core
Class QueryLogger.Builder
- java.lang.Object
-
- com.datastax.driver.core.QueryLogger.Builder
-
- Enclosing class:
- QueryLogger
public static class QueryLogger.Builder extends Object
Helper class to buildQueryLoggerinstances with a fluent API.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryLoggerbuild()Build theQueryLoggerinstance.QueryLogger.BuilderwithConstantThreshold(long slowQueryLatencyThresholdMillis)Enables slow query latency tracking based on constant thresholds.QueryLogger.BuilderwithDynamicThreshold(PercentileTracker percentileLatencyTracker, double slowQueryLatencyThresholdPercentile)Enables slow query latency tracking based on dynamic thresholds.QueryLogger.BuilderwithMaxLoggedParameters(int maxLoggedParameters)Set the maximum number of query parameters that can be logged by the driver.QueryLogger.BuilderwithMaxParameterValueLength(int maxParameterValueLength)Set the maximum length of a query parameter value that can be logged verbatim by the driver.QueryLogger.BuilderwithMaxQueryStringLength(int maxQueryStringLength)Set the maximum length of a CQL query string that can be logged verbatim by the driver.
-
-
-
Method Detail
-
withConstantThreshold
public QueryLogger.Builder withConstantThreshold(long slowQueryLatencyThresholdMillis)
Enables slow query latency tracking based on constant thresholds.Note: You should either use
constant thresholdsordynamic thresholds, not both.- Parameters:
slowQueryLatencyThresholdMillis- The threshold in milliseconds beyond which queries are considered 'slow' and logged as such by the driver. The default value isQueryLogger.DEFAULT_SLOW_QUERY_THRESHOLD_MS- Returns:
- this
QueryLogger.Builderinstance (for method chaining).
-
withDynamicThreshold
public QueryLogger.Builder withDynamicThreshold(PercentileTracker percentileLatencyTracker, double slowQueryLatencyThresholdPercentile)
Enables slow query latency tracking based on dynamic thresholds.Dynamic thresholds are based on latency percentiles, as computed by
PercentileTracker.Note: You should either use
constant thresholdsordynamic thresholds, not both.- Parameters:
percentileLatencyTracker- thePercentileTrackerinstance to use for recording latency histograms. Cannot benull. It will getregisteredwith the cluster at the same time as this logger.slowQueryLatencyThresholdPercentile- Slow queries threshold percentile. It must be comprised between 0 inclusive and 100 exclusive. The default value isQueryLogger.DEFAULT_SLOW_QUERY_THRESHOLD_PERCENTILE- Returns:
- this
QueryLogger.Builderinstance (for method chaining).
-
withMaxQueryStringLength
public QueryLogger.Builder withMaxQueryStringLength(int maxQueryStringLength)
Set the maximum length of a CQL query string that can be logged verbatim by the driver. Query strings longer than this value will be truncated when logged.- Parameters:
maxQueryStringLength- The maximum length of a CQL query string that can be logged verbatim by the driver. It must be strictly positive or-1, in which case the query is never truncated (use with care). The default value isQueryLogger.DEFAULT_MAX_QUERY_STRING_LENGTH.- Returns:
- this
QueryLogger.Builderinstance (for method chaining).
-
withMaxParameterValueLength
public QueryLogger.Builder withMaxParameterValueLength(int maxParameterValueLength)
Set the maximum length of a query parameter value that can be logged verbatim by the driver. Parameter values longer than this value will be truncated when logged.- Parameters:
maxParameterValueLength- The maximum length of a query parameter value that can be logged verbatim by the driver. It must be strictly positive or-1, in which case the parameter value is never truncated (use with care). The default value isQueryLogger.DEFAULT_MAX_PARAMETER_VALUE_LENGTH.- Returns:
- this
QueryLogger.Builderinstance (for method chaining).
-
withMaxLoggedParameters
public QueryLogger.Builder withMaxLoggedParameters(int maxLoggedParameters)
Set the maximum number of query parameters that can be logged by the driver. Queries with a number of parameters higher than this value will not have all their parameters logged.- Parameters:
maxLoggedParameters- The maximum number of query parameters that can be logged by the driver. It must be strictly positive or-1, in which case all parameters will be logged, regardless of their number (use with care). The default value isQueryLogger.DEFAULT_MAX_LOGGED_PARAMETERS.- Returns:
- this
QueryLogger.Builderinstance (for method chaining).
-
build
public QueryLogger build()
Build theQueryLoggerinstance.- Returns:
- the
QueryLoggerinstance. - Throws:
IllegalArgumentException- if the builder is unable to build a valid instance due to incorrect settings.
-
-