#include <userver/utils/statistics/recentperiod.hpp>
Class maintains circular buffer of Counters.
At any time current Counter is accessible for modification via GetCurrentCounter(). Counter can provide a Reset() member function to clear contents.
Definition at line 26 of file recentperiod.hpp.
Public Types | |
using | Duration = typename Timer::duration |
Public Member Functions | |
RecentPeriod (Duration epoch_duration=std::chrono::seconds(5), Duration max_duration=std::chrono::seconds(60)) | |
Counter & | GetCurrentCounter () |
Counter & | GetPreviousCounter (int epochs_ago) |
const Result | GetStatsForPeriod (Duration duration=Duration::min(), bool with_current_epoch=false) const |
Aggregates counters within given time range. | |
Duration | GetEpochDuration () const |
Duration | GetMaxDuration () const |
void | UpdateEpochIfOld () |
void | Reset () |
Static Public Attributes | |
static constexpr bool | kUseAddFunction |
using utils::statistics::RecentPeriod< Counter, Result, Timer >::Duration = typename Timer::duration |
Definition at line 28 of file recentperiod.hpp.
|
inline |
epoch_duration | duration of epoch. |
max_duration | max duration to calculate statistics for must be multiple of epoch_duration. |
Definition at line 44 of file recentperiod.hpp.
|
inline |
Definition at line 51 of file recentperiod.hpp.
|
inline |
Definition at line 104 of file recentperiod.hpp.
|
inline |
Definition at line 106 of file recentperiod.hpp.
|
inline |
Definition at line 53 of file recentperiod.hpp.
|
inline |
Aggregates counters within given time range.
duration | Time range. Special value Duration::min() -> use whole RecentPeriod range. |
with_current_epoch | Include current (possibly unfinished) counter into aggregation |
Type Result must have method Add(Counter, Duration, Duration) or allow addition of counter values
Definition at line 68 of file recentperiod.hpp.
|
inline |
Definition at line 110 of file recentperiod.hpp.
|
inline |
Definition at line 108 of file recentperiod.hpp.
|
staticconstexpr |
Definition at line 36 of file recentperiod.hpp.