/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
yt/cpp/mapreduce/common/debug_metrics.cpp
62 строки
1 KB
Anton Myagkov
Update ydb version to 24.4 (#4579)
07 фев 2026, 11:59
Не верифицирован
07 фев 2026, 11:59
2c21cae
Код
Авторство
О чём код?
#include "debug_metrics.h" #include <util/generic/hash.h> #include <util/generic/singleton.h> #include <util/string/cast.h> #include <util/system/mutex.h> namespace NYT { namespace NDetail { //////////////////////////////////////////////////////////////////////////////// class TDebugMetrics { public: static TDebugMetrics& Get() { return *Singleton<TDebugMetrics>(); } void Inc(TStringBuf name) { auto g = Guard(Lock_); auto it = Metrics_.find(name); if (it == Metrics_.end()) { it = Metrics_.emplace(ToString(name), 0).first; } ++it->second; } ui64 Get(TStringBuf name) const { auto g = Guard(Lock_); auto it = Metrics_.find(name); if (it == Metrics_.end()) { return 0; } else { return it->second; } } private: TMutex Lock_; THashMap<TString, ui64> Metrics_; }; //////////////////////////////////////////////////////////////////////////////// void IncDebugMetricImpl(TStringBuf name) { TDebugMetrics::Get().Inc(name); } ui64 GetDebugMetric(TStringBuf name) { return TDebugMetrics::Get().Get(name); } //////////////////////////////////////////////////////////////////////////////// } // namespace NDetail } // namespace NYT