|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.LatencyUtils.LatencyStats
public class LatencyStats
LatencyStats objects are used to track and report on the behavior of latencies across measurements.
recorded into a a given LatencyStats instance. Latencies are recorded using
recordLatency(long)
, which provides a thread safe, wait free, and lossless recording method.
The accumulated behavior across the recorded latencies in a given LatencyStats instance can be
examined in detail using interval and accumulated HdrHistogram histograms
(see Histogram
).
LatencyStats instances maintain internal histogram data that track all recoded latencies. Interval
histogram data can be sampled with the getIntervalHistogram()
,
getIntervalHistogramInto(org.HdrHistogram.Histogram)
, or addIntervalHistogramTo(org.HdrHistogram.Histogram)
calls.
Recorded latencies are auto-corrected for experienced pauses by leveraging pause detectors and
moving window average interval estimators, compensating for coordinated omission. While typical
histogram use deals with corrected data, LatencyStats instances do keep track of the raw,
uncorrected records, which can be accessed via the getLatestUncorrectedIntervalHistogram()
and getLatestUncorrectedIntervalHistogramInto(org.HdrHistogram.Histogram)
calls.
LatencyStats objects can be instantiated either directly via the provided constructors, or by
using the fluent API builder supported by LatencyStats.Builder
.
recordLatency(long)
, each
LatencyStats instance maintains an internal interval estimator that tracks the expected
interval between latency recordings. Whenever a stall in measurement is detected by a given
pause detector, each LatencyStats instances that uses that pause detector will be notified,
and will generate correcting latency entries (that are separately tracked internally).
Correcting latency entries are computed to "fill in" detected measurement pauses by projecting
the observed recording rate into the pause gap, and creating a linearly diminishing latency
measurement for each missed recording interval.
Pause detection and interval estimation are both configurable, and each LatencyStats instance can operate with potentially independent pause detector and interval estimator settings.
A configurable default pause detector is (by default) shared between LatencyStats instances
that are not provided with a specific pause detector at instantiation. If the default pause
detector is not explicitly set, it will itself default to creating (and starting) a single
instance of SimplePauseDetector
, which uses consensus observation
of a pause across multiple observing threads as a detection technique.
Custom pause detectors can be provided (by subclassing PauseDetector
).
E.g. a pause detector that pauses GC log output rather than directly measuring observations
can be constructed. A custom pause detector can be especially useful in situations where a
stall in the operation and latency measurement of an application's is known and detectable
by the application level, but would not be detectable as a process-wide stall in execution
(which SimplePauseDetector
is built to detect).
Interval estimation is done by using a time-capped moving window average estimator, with
the expected interval computed to be the average of measurement intervals within the window
(with the window being capped by both count and time). See
TimeCappedMovingAverageIntervalEstimator
for more details. The estimator window
length and time cap can both be configured when instantiating a LatencyStats object
(defaults are 1024, and 10 seconds).
Nested Class Summary | |
---|---|
static class |
LatencyStats.Builder
A fluent API builder class for creating LatencyStats objects. |
Constructor Summary | |
---|---|
LatencyStats()
Create a LatencyStats object with default settings. use the default pause detector (supplied separately set using setDefaultPauseDetector(org.LatencyUtils.PauseDetector) , which
will itself default to a SimplePauseDetector if not explicitly supplied)
use a default histogram update interval (1 sec)
use a default histogram range and accuracy (1 usec to 1hr, 2 decimal points of accuracy)
and use a default moving window estimator (1024 entry moving window, time capped at
10 seconds)
|
|
LatencyStats(long lowestTrackableLatency,
long highestTrackableLatency,
int numberOfSignificantValueDigits,
int intervalEstimatorWindowLength,
long intervalEstimatorTimeCap,
PauseDetector pauseDetector)
|
Method Summary | |
---|---|
void |
addIntervalHistogramTo(org.HdrHistogram.Histogram toHistogram)
Add the values value counts accumulated since the last interval histogram was taken into toHistogram . |
static PauseDetector |
getDefaultPauseDetector()
Get the current default pause detector which will be used by newly constructed LatencyStats instances when the constructor is not explicitly provided with one. |
IntervalEstimator |
getIntervalEstimator()
get the IntervalEstimator used by this LatencyStats object |
org.HdrHistogram.Histogram |
getIntervalHistogram()
Get a new interval histogram which will include the value counts accumulated since the last interval histogram was taken. |
void |
getIntervalHistogramInto(org.HdrHistogram.Histogram targetHistogram)
Place a copy of the value counts accumulated since the last interval histogram was taken into targetHistogram . |
org.HdrHistogram.Histogram |
getLatestUncorrectedIntervalHistogram()
Get a copy of the uncorrected latest interval latency histogram. |
void |
getLatestUncorrectedIntervalHistogramInto(org.HdrHistogram.Histogram targetHistogram)
Place a copy of the values of the latest uncorrected interval latency histogram. |
PauseDetector |
getPauseDetector()
get the PauseDetector used by this LatencyStats object |
void |
recordLatency(long latency)
Record a latency value in the LatencyStats object |
static void |
setDefaultPauseDetector(PauseDetector pauseDetector)
Set the default pause detector for the LatencyStats class. |
void |
stop()
Stop operation of this LatencyStats object, removing it from the pause detector's notification list |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LatencyStats()
setDefaultPauseDetector(org.LatencyUtils.PauseDetector)
, which
will itself default to a SimplePauseDetector
if not explicitly supplied)
public LatencyStats(long lowestTrackableLatency, long highestTrackableLatency, int numberOfSignificantValueDigits, int intervalEstimatorWindowLength, long intervalEstimatorTimeCap, PauseDetector pauseDetector)
lowestTrackableLatency
- Lowest trackable latency in latency histogramshighestTrackableLatency
- Highest trackable latency in latency histogramsnumberOfSignificantValueDigits
- Number of significant [decimal] digits of accuracy in latency histogramsintervalEstimatorWindowLength
- Length of window in moving window interval estimatorintervalEstimatorTimeCap
- Time cap (in nanoseconds) of window in moving window interval estimatorpauseDetector
- The pause detector to use for identifying and correcting for pausesMethod Detail |
---|
public static void setDefaultPauseDetector(PauseDetector pauseDetector)
pauseDetector
- the pause detector to use as a default when no explicit pause detector is providedpublic static PauseDetector getDefaultPauseDetector()
public void recordLatency(long latency)
latency
- latency value (in nanoseconds) to recordpublic org.HdrHistogram.Histogram getIntervalHistogram()
Calling getIntervalHistogram()
() will reset
the interval value counts, and start accumulating value counts for the next interval.
public void getIntervalHistogramInto(org.HdrHistogram.Histogram targetHistogram)
targetHistogram
.
Calling getIntervalHistogramInto(org.HdrHistogram.Histogram)
() will reset
the interval value counts, and start accumulating value counts for the next interval.
targetHistogram
- the histogram into which the interval histogram's data should be copiedpublic void addIntervalHistogramTo(org.HdrHistogram.Histogram toHistogram)
toHistogram
.
Calling getIntervalHistogramInto(org.HdrHistogram.Histogram)
() will reset
the interval value counts, and start accumulating value counts for the next interval.
toHistogram
- the histogram into which the interval histogram's data should be addedpublic org.HdrHistogram.Histogram getLatestUncorrectedIntervalHistogram()
getIntervalHistogram()
,
getIntervalHistogramInto(org.HdrHistogram.Histogram)
, or addIntervalHistogramTo(org.HdrHistogram.Histogram)
.
public void getLatestUncorrectedIntervalHistogramInto(org.HdrHistogram.Histogram targetHistogram)
getIntervalHistogram()
,
getIntervalHistogramInto(org.HdrHistogram.Histogram)
, or addIntervalHistogramTo(org.HdrHistogram.Histogram)
.
targetHistogram
- the histogram into which the interval histogram's data should be copiedpublic void stop()
public IntervalEstimator getIntervalEstimator()
public PauseDetector getPauseDetector()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |