userver: utils::statistics::RecentPeriod< Counter, Result, Timer > Class Template Reference
Loading...
Searching...
No Matches
utils::statistics::RecentPeriod< Counter, Result, Timer > Class Template Reference

#include <userver/utils/statistics/recentperiod.hpp>

Detailed Description

template<typename Counter, typename Result, typename Timer = utils::datetime::SteadyClock>
class utils::statistics::RecentPeriod< Counter, Result, Timer >

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.

See also
utils::statistics::Percentile

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
 

Member Typedef Documentation

◆ Duration

template<typename Counter , typename Result , typename Timer = utils::datetime::SteadyClock>
using utils::statistics::RecentPeriod< Counter, Result, Timer >::Duration = typename Timer::duration

Definition at line 28 of file recentperiod.hpp.

Constructor & Destructor Documentation

◆ RecentPeriod()

template<typename Counter , typename Result , typename Timer = utils::datetime::SteadyClock>
utils::statistics::RecentPeriod< Counter, Result, Timer >::RecentPeriod ( Duration epoch_duration = std::chrono::seconds(5),
Duration max_duration = std::chrono::seconds(60) )
inline
Parameters
epoch_durationduration of epoch.
max_durationmax duration to calculate statistics for must be multiple of epoch_duration.

Definition at line 44 of file recentperiod.hpp.

Member Function Documentation

◆ GetCurrentCounter()

template<typename Counter , typename Result , typename Timer = utils::datetime::SteadyClock>
Counter & utils::statistics::RecentPeriod< Counter, Result, Timer >::GetCurrentCounter ( )
inline

Definition at line 51 of file recentperiod.hpp.

◆ GetEpochDuration()

template<typename Counter , typename Result , typename Timer = utils::datetime::SteadyClock>
Duration utils::statistics::RecentPeriod< Counter, Result, Timer >::GetEpochDuration ( ) const
inline

Definition at line 104 of file recentperiod.hpp.

◆ GetMaxDuration()

template<typename Counter , typename Result , typename Timer = utils::datetime::SteadyClock>
Duration utils::statistics::RecentPeriod< Counter, Result, Timer >::GetMaxDuration ( ) const
inline

Definition at line 106 of file recentperiod.hpp.

◆ GetPreviousCounter()

template<typename Counter , typename Result , typename Timer = utils::datetime::SteadyClock>
Counter & utils::statistics::RecentPeriod< Counter, Result, Timer >::GetPreviousCounter ( int epochs_ago)
inline

Definition at line 53 of file recentperiod.hpp.

◆ GetStatsForPeriod()

template<typename Counter , typename Result , typename Timer = utils::datetime::SteadyClock>
const Result utils::statistics::RecentPeriod< Counter, Result, Timer >::GetStatsForPeriod ( Duration duration = Duration::min(),
bool with_current_epoch = false ) const
inline

Aggregates counters within given time range.

Parameters
durationTime range. Special value Duration::min() -> use whole RecentPeriod range.
with_current_epochInclude 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.

◆ Reset()

template<typename Counter , typename Result , typename Timer = utils::datetime::SteadyClock>
void utils::statistics::RecentPeriod< Counter, Result, Timer >::Reset ( )
inline

Definition at line 110 of file recentperiod.hpp.

◆ UpdateEpochIfOld()

template<typename Counter , typename Result , typename Timer = utils::datetime::SteadyClock>
void utils::statistics::RecentPeriod< Counter, Result, Timer >::UpdateEpochIfOld ( )
inline

Definition at line 108 of file recentperiod.hpp.

Member Data Documentation

◆ kUseAddFunction

template<typename Counter , typename Result , typename Timer = utils::datetime::SteadyClock>
constexpr bool utils::statistics::RecentPeriod< Counter, Result, Timer >::kUseAddFunction
staticconstexpr
Initial value:
=
detail::kResultWantsAddFunction<Result, Counter, Duration>

Definition at line 36 of file recentperiod.hpp.


The documentation for this class was generated from the following file: