
io.lettuce.core.metrics.CommandMetrics Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lettuce-core Show documentation
Show all versions of lettuce-core Show documentation
Advanced and thread-safe Java Redis client for synchronous, asynchronous, and
reactive usage. Supports Cluster, Sentinel, Pipelining, Auto-Reconnect, Codecs
and much more.
The newest version!
package io.lettuce.core.metrics;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* Latency metrics for commands. This class provides the count, time unit and firstResponse/completion latencies.
*
* @author Mark Paluch
*/
public class CommandMetrics {
private final long count;
private final TimeUnit timeUnit;
private final CommandLatency firstResponse;
private final CommandLatency completion;
public CommandMetrics(long count, TimeUnit timeUnit, CommandLatency firstResponse, CommandLatency completion) {
this.count = count;
this.timeUnit = timeUnit;
this.firstResponse = firstResponse;
this.completion = completion;
}
/**
*
* @return the count
*/
public long getCount() {
return count;
}
/**
*
* @return the time unit for the {@link #getFirstResponse()} and {@link #getCompletion()} latencies.
*/
public TimeUnit getTimeUnit() {
return timeUnit;
}
/**
*
* @return latencies between send and the first command response
*/
public CommandLatency getFirstResponse() {
return firstResponse;
}
/**
*
* @return latencies between send and the command completion
*/
public CommandLatency getCompletion() {
return completion;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[count=").append(count);
sb.append(", timeUnit=").append(timeUnit);
sb.append(", firstResponse=").append(firstResponse);
sb.append(", completion=").append(completion);
sb.append(']');
return sb.toString();
}
public static class CommandLatency {
private final long min;
private final long max;
private final Map percentiles;
public CommandLatency(long min, long max, Map percentiles) {
this.min = min;
this.max = max;
this.percentiles = percentiles;
}
/**
*
* @return the minimum time
*/
public long getMin() {
return min;
}
/**
*
* @return the maximum time
*/
public long getMax() {
return max;
}
/**
*
* @return percentile mapping
*/
public Map getPercentiles() {
return percentiles;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[min=").append(min);
sb.append(", max=").append(max);
sb.append(", percentiles=").append(percentiles);
sb.append(']');
return sb.toString();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy