#pragma once #include #include namespace NMonitoring { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Percentile tracker for monitoring //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// struct TPercentileBase : public TThrRefBase { using TPercentile = std::pair; using TPercentiles = TVector; TPercentiles Percentiles; void Initialize(const TIntrusivePtr &counters, const TVector &thresholds, TCountableBase::EVisibility visibility = TCountableBase::EVisibility::Public) { Percentiles.reserve(thresholds.size()); for (size_t i = 0; i < thresholds.size(); ++i) { Percentiles.emplace_back(thresholds[i], counters->GetNamedCounter("percentile", Sprintf("%.1f", thresholds[i] * 100.f), false, visibility)); } } void Initialize(const TIntrusivePtr &counters, TString group, TString subgroup, TString name, const TVector &thresholds, TCountableBase::EVisibility visibility = TCountableBase::EVisibility::Public) { auto subCounters = counters->GetSubgroup(group, subgroup)->GetSubgroup("sensor", name); Initialize(subCounters, thresholds, visibility); } }; } // NMonitoring