Package io.lettuce.core.metrics
Class DefaultCommandLatencyCollector
- java.lang.Object
-
- io.lettuce.core.metrics.DefaultCommandLatencyCollector
-
- All Implemented Interfaces:
CommandLatencyCollector
,CommandLatencyRecorder
,MetricCollector<Map<CommandLatencyId,CommandMetrics>>
public class DefaultCommandLatencyCollector extends Object implements CommandLatencyCollector
Default implementation of aCommandLatencyCollector
for command latencies.- Author:
- Mark Paluch, Bryce J. Fisher
-
-
Constructor Summary
Constructors Constructor Description DefaultCommandLatencyCollector(CommandLatencyCollectorOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CommandLatencyCollector
disabled()
Returns a disabled no-opCommandLatencyCollector
.static boolean
isAvailable()
Returnstrue
if HdrUtils and LatencyUtils are available on the class path.boolean
isEnabled()
Returnstrue
if the metric collector is enabled.void
recordCommandLatency(SocketAddress local, SocketAddress remote, ProtocolKeyword commandType, long firstResponseLatency, long completionLatency)
Record the command latency perconnectionPoint
andcommandType
.Map<CommandLatencyId,CommandMetrics>
retrieveMetrics()
Returns the collected/aggregated metrics.void
shutdown()
Shut down the metrics collector.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.lettuce.core.metrics.CommandLatencyRecorder
recordCommandLatency
-
-
-
-
Constructor Detail
-
DefaultCommandLatencyCollector
public DefaultCommandLatencyCollector(CommandLatencyCollectorOptions options)
-
-
Method Detail
-
recordCommandLatency
public void recordCommandLatency(SocketAddress local, SocketAddress remote, ProtocolKeyword commandType, long firstResponseLatency, long completionLatency)
Record the command latency perconnectionPoint
andcommandType
.- Specified by:
recordCommandLatency
in interfaceCommandLatencyRecorder
- Parameters:
local
- the local addressremote
- the remote addresscommandType
- the command typefirstResponseLatency
- latency value inTimeUnit.NANOSECONDS
from send to the first responsecompletionLatency
- latency value inTimeUnit.NANOSECONDS
from send to the command completion
-
isEnabled
public boolean isEnabled()
Description copied from interface:CommandLatencyRecorder
Returnstrue
if the metric collector is enabled.- Specified by:
isEnabled
in interfaceCommandLatencyRecorder
- Returns:
true
if the metric collector is enabled
-
shutdown
public void shutdown()
Description copied from interface:MetricCollector
Shut down the metrics collector.- Specified by:
shutdown
in interfaceMetricCollector<Map<CommandLatencyId,CommandMetrics>>
-
retrieveMetrics
public Map<CommandLatencyId,CommandMetrics> retrieveMetrics()
Description copied from interface:MetricCollector
Returns the collected/aggregated metrics.- Specified by:
retrieveMetrics
in interfaceMetricCollector<Map<CommandLatencyId,CommandMetrics>>
- Returns:
- the collected/aggregated metrics
-
isAvailable
public static boolean isAvailable()
Returnstrue
if HdrUtils and LatencyUtils are available on the class path.- Returns:
-
disabled
public static CommandLatencyCollector disabled()
Returns a disabled no-opCommandLatencyCollector
.- Returns:
-
-