java.lang.Object
io.prometheus.metrics.core.metrics.SlidingWindow<T>
Maintains a ring buffer of T to implement a sliding time window.
This is used to maintain a sliding window of CKMSQuantiles for Summary
metrics.
It is implemented in a generic way so that 3rd party libraries can use it for implementing sliding windows.
TODO: The current implementation is synchronized. There is likely room for
optimization.
-
Constructor Summary
ConstructorsConstructorDescriptionSlidingWindow(Class<T> clazz, Supplier<T> constructor, ObjDoubleConsumer<T> observeFunction, long maxAgeSeconds, int ageBuckets) Example: If themaxAgeSecondsis 60 andageBucketsis 3, then 3 instances ofTare maintained and the sliding window moves to the next instance of T every 20 seconds. -
Method Summary
-
Constructor Details
-
SlidingWindow
public SlidingWindow(Class<T> clazz, Supplier<T> constructor, ObjDoubleConsumer<T> observeFunction, long maxAgeSeconds, int ageBuckets) Example: If themaxAgeSecondsis 60 andageBucketsis 3, then 3 instances ofTare maintained and the sliding window moves to the next instance of T every 20 seconds.- Parameters:
clazz- type of Tconstructor- for creating a new instance of T as the old one gets evictedobserveFunction- for observing a value (e.g. callingt.observe(value)maxAgeSeconds- after this amount of time an instance of T gets evicted.ageBuckets- number of age buckets.
-
-
Method Details
-
current
Get the currently active instance ofT. -
observe
public void observe(double value) Observe a value.
-