This class represents a bucketed time series which keeps track of values added in the recent past, and merges these values together into a fixed number of buckets to keep a lid on memory use if the number of values added is very large.
Synopsis
Declared in <folly/stats/BucketedTimeSeries.h>
template<
typename VT,
typename CT = LegacyStatsClock<std::chrono::seconds>>
class BucketedTimeSeries;
Description
For example, a BucketedTimeSeries() with duration == 60s and 10 buckets will keep track of 10 6‐second buckets, and discard all data added more than 1 minute ago. As time ticks by, a 6‐second bucket at a time will be discarded and new data will go into the newly opened bucket. Internally, it uses a circular array of buckets that it reuses as time advances.
This class assumes that time advances forwards. The window of time tracked by the timeseries will advance forwards whenever a more recent timestamp is passed to addValue(). While it is possible to pass old time values to addValue(), this will never move the time window backwards. If the old time value falls outside the tracked window of time, the data point will be ignored.
This class is not thread‐safe ‐‐ use your own synchronization!
Type Aliases
Member Functions
Name |
Description |
|
Create a new BucketedTimeSeries. |
|
|
|
|
|
|
Returns actual buckets of values |
|
Reset the timeseries to an empty state, as if no data points have ever been added to it. |
|
|
|
|
|
Return the maximum duration of data that can be tracked by this BucketedTimeSeries. |
|
|
|
Returns true if no calls to update() have been made since the last call to clear(). |
|
Returns the oldest time observed either by adding value or calling update() since clear()/constructor. Note that the returned value is only meaningful when empty() is false. |
|
Invoke a function for each bucket. |
|
Get the bucket at the specified index. |
|
Get the index for the bucket containing the specified time. |
|
Compute the bucket index that the specified time falls into, as well as the bucket start time and the next bucket's start time. |
|
Get the time of the earliest data point stored in this timeseries. |
|
For a non‐all‐time timeseries, return the earliest time that could be tracked by the timeseries with the provided latest time. It can return a time point that is earlier than firstTime_. |
|
See latestTime() |
|
Returns true if this BucketedTimeSeries stores data for all‐time, without ever rolling over into new buckets. |
|
Returns the latest time observed either by adding value or calling update() since clear()/constructor. Note that the returned value is only meaningful when empty() is false. |
|
Return the number of buckets. |
|
|
|
Compute a rate from a numerator and an elapsed time. |
|
|
|
Return the total (sum and count) of the tracked buckets that overlap with [getEarliestTrackableTimeBy(now), now]. |
|
|
Created with MrDocs