#pragma once #include #include #include #include namespace NUnifiedAgent { class TDurationUsCounter { public: class TScope { public: TScope(TDurationUsCounter& counter) : Counter(counter) , StartTime(Counter.Begin()) { } ~TScope() { Counter.End(StartTime); } private: TDurationUsCounter& Counter; NHPTimer::STime* StartTime; }; public: TDurationUsCounter(const TString& name, NMonitoring::TDynamicCounters& owner); NHPTimer::STime* Begin(); void End(NHPTimer::STime* startTime); void Update(); private: NMonitoring::TDeprecatedCounter& Counter; TDeque ActiveTimers; TAdaptiveLock Lock; }; }