#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 25 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 27 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 42 of file recentperiod.hpp.
|
inline |
Definition at line 50 of file recentperiod.hpp.
|
inline |
Definition at line 97 of file recentperiod.hpp.
|
inline |
Definition at line 99 of file recentperiod.hpp.
|
inline |
Definition at line 52 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 65 of file recentperiod.hpp.
|
inline |
Definition at line 103 of file recentperiod.hpp.
|
inline |
Definition at line 101 of file recentperiod.hpp.
|
staticconstexpr |
Definition at line 35 of file recentperiod.hpp.