#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 24 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 = detail::kResultWantsAddFunction<Result, Counter, Duration> |
using utils::statistics::RecentPeriod< Counter, Result, Timer >::Duration = typename Timer::duration |
Definition at line 26 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 41 of file recentperiod.hpp.
|
inline |
Definition at line 47 of file recentperiod.hpp.
|
inline |
Definition at line 94 of file recentperiod.hpp.
|
inline |
Definition at line 96 of file recentperiod.hpp.
|
inline |
Definition at line 49 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 62 of file recentperiod.hpp.
|
inline |
Definition at line 100 of file recentperiod.hpp.
|
inline |
Definition at line 98 of file recentperiod.hpp.
|
staticconstexpr |
Definition at line 34 of file recentperiod.hpp.