Package com.gigaspaces.metrics
Class LatencyGauge
Deprecated.
A metric which measures average latency value using sampling.
Each latency (measured in nanoseconds) is recorded and added to the total latencies.
When getValue() is called the average is calculated and returned, resetting the measurement.
Throughput and latency are not directly inversely proportional, but can be related by the formula:
Throughput = 1 / (Latency + Processing Time)
If Processing Time is negligible or close to zero, then a latency of 100 milliseconds is:
Throughput = 1 / (100 milliseconds) ≈ 10 writes per second
DEPRECATED: Use Micrometer Timer which provides
comprehensive latency metrics (count, total time, max, percentiles, histogram).
Migration Guide:
// OLD:
LatencyGauge latency = new LatencyGauge();
long start = System.nanoTime();
// ... operation ...
latency.set(System.nanoTime() - start);
Long avgLatency = latency.getValue();
// NEW:
Timer timer = Timer.builder("operation_duration")
.tags(tags)
.description("Duration of operation")
.register(meterRegistry);
// Option 1: Lambda style
timer.record(() -> {
// ... operation ...
});
// Option 2: Timer.Sample (for async operations)
Timer.Sample sample = Timer.start();
// ... operation ...
sample.stop(timer);
// Access metrics:
long count = timer.count();
double totalTime = timer.totalTime(TimeUnit.NANOSECONDS);
double mean = timer.mean(TimeUnit.NANOSECONDS);
double max = timer.max(TimeUnit.NANOSECONDS);
- Since:
- 16.5
- Author:
- Moran
- See Also:
-
Timer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetValue()Deprecated.Returns the metric's current value.voidrecordValue(long latencyNanos) Deprecated.Methods inherited from class com.gigaspaces.metrics.Gauge
calculatePercent, validate
-
Constructor Details
-
LatencyGauge
public LatencyGauge()Deprecated.
-
-
Method Details
-
recordValue
public void recordValue(long latencyNanos) Deprecated.- Parameters:
latencyNanos- latency of operation in nanoseconds
-
getValue
Deprecated.Description copied from class:GaugeReturns the metric's current value.
-
Timerfor latency measurements