diff options
author | monster <monster@yandex-team.ru> | 2022-02-10 16:47:19 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:19 +0300 |
commit | b23c1d7a8015c2006a148fd93b84cdeb0aee17a3 (patch) | |
tree | 9814fbd1c3effac9b8377c5d604b367b14e2db55 /library/cpp/monlib | |
parent | dd76ae1f6213d065375ab296699f764faafbe5bd (diff) | |
download | ydb-b23c1d7a8015c2006a148fd93b84cdeb0aee17a3.tar.gz |
Restoring authorship annotation for <monster@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib')
-rw-r--r-- | library/cpp/monlib/dynamic_counters/contention_ut.cpp | 2 | ||||
-rw-r--r-- | library/cpp/monlib/dynamic_counters/counters.cpp | 64 | ||||
-rw-r--r-- | library/cpp/monlib/dynamic_counters/counters.h | 66 | ||||
-rw-r--r-- | library/cpp/monlib/dynamic_counters/counters_ut.cpp | 58 | ||||
-rw-r--r-- | library/cpp/monlib/dynamic_counters/encode.cpp | 16 | ||||
-rw-r--r-- | library/cpp/monlib/dynamic_counters/golovan_page.cpp | 2 | ||||
-rw-r--r-- | library/cpp/monlib/dynamic_counters/page.cpp | 8 | ||||
-rw-r--r-- | library/cpp/monlib/dynamic_counters/ya.make | 2 | ||||
-rw-r--r-- | library/cpp/monlib/service/pages/mon_page.h | 2 |
9 files changed, 110 insertions, 110 deletions
diff --git a/library/cpp/monlib/dynamic_counters/contention_ut.cpp b/library/cpp/monlib/dynamic_counters/contention_ut.cpp index d142397e1a..8798044ee3 100644 --- a/library/cpp/monlib/dynamic_counters/contention_ut.cpp +++ b/library/cpp/monlib/dynamic_counters/contention_ut.cpp @@ -33,7 +33,7 @@ Y_UNIT_TEST_SUITE(TDynamicCountersContentionTest) { Response.Wait(); } - void OnHistogram(const TString& /*labelName*/, const TString& /*labelValue*/, IHistogramSnapshotPtr /*snapshot*/, bool /*derivative*/) override { + void OnHistogram(const TString& /*labelName*/, const TString& /*labelValue*/, IHistogramSnapshotPtr /*snapshot*/, bool /*derivative*/) override { } void OnGroupBegin(const TString& /*labelName*/, const TString& /*labelValue*/, const TDynamicCounters* /*group*/) override { diff --git a/library/cpp/monlib/dynamic_counters/counters.cpp b/library/cpp/monlib/dynamic_counters/counters.cpp index 977c8ea7b0..3635d87d0d 100644 --- a/library/cpp/monlib/dynamic_counters/counters.cpp +++ b/library/cpp/monlib/dynamic_counters/counters.cpp @@ -70,38 +70,38 @@ TDynamicCounters::TCounterPtr TDynamicCounters::GetNamedCounter(const TString& n return AsCounterRef(GetNamedCounterImpl<false, TCounterForPtr>(name, value, derivative, vis)); } -THistogramPtr TDynamicCounters::GetHistogram(const TString& value, IHistogramCollectorPtr collector, bool derivative, EVisibility vis) { - return GetNamedHistogram("sensor", value, std::move(collector), derivative, vis); +THistogramPtr TDynamicCounters::GetHistogram(const TString& value, IHistogramCollectorPtr collector, bool derivative, EVisibility vis) { + return GetNamedHistogram("sensor", value, std::move(collector), derivative, vis); } -THistogramPtr TDynamicCounters::GetNamedHistogram(const TString& name, const TString& value, IHistogramCollectorPtr collector, bool derivative, EVisibility vis) { - return AsHistogramRef(GetNamedCounterImpl<false, THistogramCounter>(name, value, std::move(collector), derivative, vis)); +THistogramPtr TDynamicCounters::GetNamedHistogram(const TString& name, const TString& value, IHistogramCollectorPtr collector, bool derivative, EVisibility vis) { + return AsHistogramRef(GetNamedCounterImpl<false, THistogramCounter>(name, value, std::move(collector), derivative, vis)); } -THistogramPtr TDynamicCounters::GetExpiringHistogram(const TString& value, IHistogramCollectorPtr collector, bool derivative, EVisibility vis) { - return GetExpiringNamedHistogram("sensor", value, std::move(collector), derivative, vis); +THistogramPtr TDynamicCounters::GetExpiringHistogram(const TString& value, IHistogramCollectorPtr collector, bool derivative, EVisibility vis) { + return GetExpiringNamedHistogram("sensor", value, std::move(collector), derivative, vis); } -THistogramPtr TDynamicCounters::GetExpiringNamedHistogram(const TString& name, const TString& value, IHistogramCollectorPtr collector, bool derivative, EVisibility vis) { - return AsHistogramRef(GetNamedCounterImpl<true, TExpiringHistogramCounter>(name, value, std::move(collector), derivative, vis)); +THistogramPtr TDynamicCounters::GetExpiringNamedHistogram(const TString& name, const TString& value, IHistogramCollectorPtr collector, bool derivative, EVisibility vis) { + return AsHistogramRef(GetNamedCounterImpl<true, TExpiringHistogramCounter>(name, value, std::move(collector), derivative, vis)); +} + +TDynamicCounters::TCounterPtr TDynamicCounters::FindCounter(const TString& value) const { + return FindNamedCounter("sensor", value); +} + +TDynamicCounters::TCounterPtr TDynamicCounters::FindNamedCounter(const TString& name, const TString& value) const { + return AsCounterRef(FindNamedCounterImpl<TCounterForPtr>(name, value)); +} + +THistogramPtr TDynamicCounters::FindHistogram(const TString& value) const { + return FindNamedHistogram("sensor", value); +} + +THistogramPtr TDynamicCounters::FindNamedHistogram(const TString& name,const TString& value) const { + return AsHistogramRef(FindNamedCounterImpl<THistogramCounter>(name, value)); } -TDynamicCounters::TCounterPtr TDynamicCounters::FindCounter(const TString& value) const { - return FindNamedCounter("sensor", value); -} - -TDynamicCounters::TCounterPtr TDynamicCounters::FindNamedCounter(const TString& name, const TString& value) const { - return AsCounterRef(FindNamedCounterImpl<TCounterForPtr>(name, value)); -} - -THistogramPtr TDynamicCounters::FindHistogram(const TString& value) const { - return FindNamedHistogram("sensor", value); -} - -THistogramPtr TDynamicCounters::FindNamedHistogram(const TString& name,const TString& value) const { - return AsHistogramRef(FindNamedCounterImpl<THistogramCounter>(name, value)); -} - void TDynamicCounters::RemoveCounter(const TString &value) { RemoveNamedCounter("sensor", value); } @@ -298,11 +298,11 @@ TDynamicCounters::TCountablePtr TDynamicCounters::GetNamedCounterImpl(const TStr } return it->second; } - -template <class TCounterType> -TDynamicCounters::TCountablePtr TDynamicCounters::FindNamedCounterImpl(const TString& name, const TString& value) const { - TReadGuard g(Lock); - auto it = Counters.find({name, value}); - return it != Counters.end() ? it->second : nullptr; -} - + +template <class TCounterType> +TDynamicCounters::TCountablePtr TDynamicCounters::FindNamedCounterImpl(const TString& name, const TString& value) const { + TReadGuard g(Lock); + auto it = Counters.find({name, value}); + return it != Counters.end() ? it->second : nullptr; +} + diff --git a/library/cpp/monlib/dynamic_counters/counters.h b/library/cpp/monlib/dynamic_counters/counters.h index 9882001de5..dc178cfbe0 100644 --- a/library/cpp/monlib/dynamic_counters/counters.h +++ b/library/cpp/monlib/dynamic_counters/counters.h @@ -66,7 +66,7 @@ namespace NMonitoring { virtual void OnHistogram( const TString& labelName, const TString& labelValue, - IHistogramSnapshotPtr snapshot, bool derivative) = 0; + IHistogramSnapshotPtr snapshot, bool derivative) = 0; virtual void OnGroupBegin( const TString& labelName, const TString& labelValue, @@ -93,8 +93,8 @@ namespace NMonitoring { Visibility_ = vis; } - TCounterForPtr(const TCounterForPtr&) = delete; - TCounterForPtr& operator=(const TCounterForPtr& other) = delete; + TCounterForPtr(const TCounterForPtr&) = delete; + TCounterForPtr& operator=(const TCounterForPtr& other) = delete; void Accept( const TString& labelName, const TString& labelValue, @@ -129,10 +129,10 @@ namespace NMonitoring { }; struct THistogramCounter: public TCountableBase { - explicit THistogramCounter( - IHistogramCollectorPtr collector, bool derivative = true, EVisibility vis = EVisibility::Public) + explicit THistogramCounter( + IHistogramCollectorPtr collector, bool derivative = true, EVisibility vis = EVisibility::Public) : Collector_(std::move(collector)) - , Derivative_(derivative) + , Derivative_(derivative) { Visibility_ = vis; } @@ -145,34 +145,34 @@ namespace NMonitoring { Collector_->Collect(value, count); } - void Collect(double value, ui32 count) { - Collector_->Collect(value, count); - } - - void Collect(const IHistogramSnapshot& snapshot) { - Collector_->Collect(snapshot); - } - + void Collect(double value, ui32 count) { + Collector_->Collect(value, count); + } + + void Collect(const IHistogramSnapshot& snapshot) { + Collector_->Collect(snapshot); + } + void Accept( const TString& labelName, const TString& labelValue, ICountableConsumer& consumer) const override { if (IsVisible(Visibility(), consumer.Visibility())) { - consumer.OnHistogram(labelName, labelValue, Collector_->Snapshot(), Derivative_); + consumer.OnHistogram(labelName, labelValue, Collector_->Snapshot(), Derivative_); } } - void Reset() { - Collector_->Reset(); - } - + void Reset() { + Collector_->Reset(); + } + IHistogramSnapshotPtr Snapshot() const { return Collector_->Snapshot(); } private: IHistogramCollectorPtr Collector_; - bool Derivative_; + bool Derivative_; }; struct TExpiringHistogramCounter: public THistogramCounter { @@ -284,14 +284,14 @@ namespace NMonitoring { THistogramPtr GetHistogram( const TString& value, IHistogramCollectorPtr collector, - bool derivative = true, + bool derivative = true, TCountableBase::EVisibility visibility = TCountableBase::EVisibility::Public); THistogramPtr GetNamedHistogram( const TString& name, const TString& value, IHistogramCollectorPtr collector, - bool derivative = true, + bool derivative = true, TCountableBase::EVisibility visibility = TCountableBase::EVisibility::Public); // These counters will be automatically removed from the registry @@ -310,22 +310,22 @@ namespace NMonitoring { THistogramPtr GetExpiringHistogram( const TString& value, IHistogramCollectorPtr collector, - bool derivative = true, + bool derivative = true, TCountableBase::EVisibility visibility = TCountableBase::EVisibility::Public); THistogramPtr GetExpiringNamedHistogram( const TString& name, const TString& value, IHistogramCollectorPtr collector, - bool derivative = true, + bool derivative = true, TCountableBase::EVisibility visibility = TCountableBase::EVisibility::Public); - TCounterPtr FindCounter(const TString& value) const; - TCounterPtr FindNamedCounter(const TString& name, const TString& value) const; - - THistogramPtr FindHistogram(const TString& value) const; - THistogramPtr FindNamedHistogram(const TString& name,const TString& value) const; - + TCounterPtr FindCounter(const TString& value) const; + TCounterPtr FindNamedCounter(const TString& name, const TString& value) const; + + THistogramPtr FindHistogram(const TString& value) const; + THistogramPtr FindNamedHistogram(const TString& name,const TString& value) const; + void RemoveCounter(const TString &value); void RemoveNamedCounter(const TString& name, const TString &value); @@ -366,9 +366,9 @@ namespace NMonitoring { template <bool expiring, class TCounterType, class... TArgs> TCountablePtr GetNamedCounterImpl(const TString& name, const TString& value, TArgs&&... args); - - template <class TCounterType> - TCountablePtr FindNamedCounterImpl(const TString& name, const TString& value) const; + + template <class TCounterType> + TCountablePtr FindNamedCounterImpl(const TString& name, const TString& value) const; }; } diff --git a/library/cpp/monlib/dynamic_counters/counters_ut.cpp b/library/cpp/monlib/dynamic_counters/counters_ut.cpp index 04285ae5e3..3591037e0a 100644 --- a/library/cpp/monlib/dynamic_counters/counters_ut.cpp +++ b/library/cpp/monlib/dynamic_counters/counters_ut.cpp @@ -23,7 +23,7 @@ private: void OnHistogram( const TString& labelName, const TString& labelValue, - IHistogramSnapshotPtr snapshot, bool /*derivative*/) override { + IHistogramSnapshotPtr snapshot, bool /*derivative*/) override { Indent(Out_, Level_) << labelName << ':' << labelValue << " = " << *snapshot << '\n'; @@ -311,32 +311,32 @@ Y_UNIT_TEST_SUITE(TDynamicCountersTest) { UNIT_ASSERT_VALUES_EQUAL(subGroupLookups->Val(), 1); UNIT_ASSERT_VALUES_EQUAL(lookups->Val(), 5); } - - Y_UNIT_TEST(FindCounters) { - TDynamicCounterPtr rootGroup(new TDynamicCounters()); - - auto counter = rootGroup->FindCounter("counter1"); - UNIT_ASSERT(!counter); - rootGroup->GetCounter("counter1"); - counter = rootGroup->FindCounter("counter1"); - UNIT_ASSERT(counter); - - counter = rootGroup->FindNamedCounter("name", "counter2"); - UNIT_ASSERT(!counter); - rootGroup->GetNamedCounter("name", "counter2"); - counter = rootGroup->FindNamedCounter("name", "counter2"); - UNIT_ASSERT(counter); - - auto histogram = rootGroup->FindHistogram("histogram1"); - UNIT_ASSERT(!histogram); - rootGroup->GetHistogram("histogram1", ExponentialHistogram(4, 2)); - histogram = rootGroup->FindHistogram("histogram1"); - UNIT_ASSERT(histogram); - - histogram = rootGroup->FindNamedHistogram("name", "histogram2"); - UNIT_ASSERT(!histogram); - rootGroup->GetNamedHistogram("name", "histogram2", ExponentialHistogram(4, 2)); - histogram = rootGroup->FindNamedHistogram("name", "histogram2"); - UNIT_ASSERT(histogram); - } + + Y_UNIT_TEST(FindCounters) { + TDynamicCounterPtr rootGroup(new TDynamicCounters()); + + auto counter = rootGroup->FindCounter("counter1"); + UNIT_ASSERT(!counter); + rootGroup->GetCounter("counter1"); + counter = rootGroup->FindCounter("counter1"); + UNIT_ASSERT(counter); + + counter = rootGroup->FindNamedCounter("name", "counter2"); + UNIT_ASSERT(!counter); + rootGroup->GetNamedCounter("name", "counter2"); + counter = rootGroup->FindNamedCounter("name", "counter2"); + UNIT_ASSERT(counter); + + auto histogram = rootGroup->FindHistogram("histogram1"); + UNIT_ASSERT(!histogram); + rootGroup->GetHistogram("histogram1", ExponentialHistogram(4, 2)); + histogram = rootGroup->FindHistogram("histogram1"); + UNIT_ASSERT(histogram); + + histogram = rootGroup->FindNamedHistogram("name", "histogram2"); + UNIT_ASSERT(!histogram); + rootGroup->GetNamedHistogram("name", "histogram2", ExponentialHistogram(4, 2)); + histogram = rootGroup->FindNamedHistogram("name", "histogram2"); + UNIT_ASSERT(histogram); + } } diff --git a/library/cpp/monlib/dynamic_counters/encode.cpp b/library/cpp/monlib/dynamic_counters/encode.cpp index 6f5005f71a..ffa48d276e 100644 --- a/library/cpp/monlib/dynamic_counters/encode.cpp +++ b/library/cpp/monlib/dynamic_counters/encode.cpp @@ -3,7 +3,7 @@ #include <library/cpp/monlib/encode/encoder.h> #include <library/cpp/monlib/encode/json/json.h> #include <library/cpp/monlib/encode/spack/spack_v1.h> -#include <library/cpp/monlib/encode/prometheus/prometheus.h> +#include <library/cpp/monlib/encode/prometheus/prometheus.h> #include <util/stream/str.h> @@ -41,10 +41,10 @@ namespace NMonitoring { void OnHistogram( const TString& labelName, const TString& labelValue, - IHistogramSnapshotPtr snapshot, bool derivative) override { - NMonitoring::EMetricType metricType = derivative ? EMetricType::HIST_RATE : EMetricType::HIST; - - EncoderImpl_->OnMetricBegin(metricType); + IHistogramSnapshotPtr snapshot, bool derivative) override { + NMonitoring::EMetricType metricType = derivative ? EMetricType::HIST_RATE : EMetricType::HIST; + + EncoderImpl_->OnMetricBegin(metricType); EncodeLabels(labelName, labelValue); EncoderImpl_->OnHistogram(ZERO_TIME, snapshot); EncoderImpl_->OnMetricEnd(); @@ -104,9 +104,9 @@ namespace NMonitoring { out, NMonitoring::ETimePrecision::SECONDS, NMonitoring::ECompression::ZSTD), vis); - case EFormat::PROMETHEUS: - return MakeHolder<TConsumer>(NMonitoring::EncoderPrometheus( - out), vis); + case EFormat::PROMETHEUS: + return MakeHolder<TConsumer>(NMonitoring::EncoderPrometheus( + out), vis); default: ythrow yexception() << "unsupported metric encoding format: " << format; break; diff --git a/library/cpp/monlib/dynamic_counters/golovan_page.cpp b/library/cpp/monlib/dynamic_counters/golovan_page.cpp index 6d76956234..49cf2d39bb 100644 --- a/library/cpp/monlib/dynamic_counters/golovan_page.cpp +++ b/library/cpp/monlib/dynamic_counters/golovan_page.cpp @@ -39,7 +39,7 @@ public: out << "\"," << counter->Val() << "]"; } - void OnHistogram(const TString&, const TString&, IHistogramSnapshotPtr, bool) override { + void OnHistogram(const TString&, const TString&, IHistogramSnapshotPtr, bool) override { } void OnGroupBegin(const TString&, const TString& value, const TDynamicCounters*) override { diff --git a/library/cpp/monlib/dynamic_counters/page.cpp b/library/cpp/monlib/dynamic_counters/page.cpp index 812ee6b4ca..5124a47bb3 100644 --- a/library/cpp/monlib/dynamic_counters/page.cpp +++ b/library/cpp/monlib/dynamic_counters/page.cpp @@ -19,8 +19,8 @@ TMaybe<EFormat> ParseFormat(TStringBuf str) { return EFormat::JSON; } else if (str == TStringBuf("spack")) { return EFormat::SPACK; - } else if (str == TStringBuf("prometheus")) { - return EFormat::PROMETHEUS; + } else if (str == TStringBuf("prometheus")) { + return EFormat::PROMETHEUS; } else { return Nothing(); } @@ -84,8 +84,8 @@ void TDynamicCountersPage::Output(NMonitoring::IMonHttpRequest& request) { out << HTTPOKJSON; } else if (*format == EFormat::SPACK) { out << HTTPOKSPACK; - } else if (*format == EFormat::PROMETHEUS) { - out << HTTPOKPROMETHEUS; + } else if (*format == EFormat::PROMETHEUS) { + out << HTTPOKPROMETHEUS; } else { ythrow yexception() << "unsupported metric encoding format: " << *format; } diff --git a/library/cpp/monlib/dynamic_counters/ya.make b/library/cpp/monlib/dynamic_counters/ya.make index 0b1e97fa4e..aafe1c34be 100644 --- a/library/cpp/monlib/dynamic_counters/ya.make +++ b/library/cpp/monlib/dynamic_counters/ya.make @@ -18,7 +18,7 @@ PEERDIR( library/cpp/containers/stack_vector library/cpp/monlib/encode/json library/cpp/monlib/encode/spack - library/cpp/monlib/encode/prometheus + library/cpp/monlib/encode/prometheus library/cpp/monlib/service/pages library/cpp/string_utils/quote library/cpp/threading/light_rw_lock diff --git a/library/cpp/monlib/service/pages/mon_page.h b/library/cpp/monlib/service/pages/mon_page.h index ad7afb867d..e396612bb0 100644 --- a/library/cpp/monlib/service/pages/mon_page.h +++ b/library/cpp/monlib/service/pages/mon_page.h @@ -12,7 +12,7 @@ namespace NMonitoring { static const char HTTPOKHTML[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/html\r\nConnection: Close\r\n\r\n"; static const char HTTPOKJSON[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/json\r\nConnection: Close\r\n\r\n"; static const char HTTPOKSPACK[] = "HTTP/1.1 200 Ok\r\nContent-Type: application/x-solomon-spack\r\nConnection: Close\r\n\r\n"; - static const char HTTPOKPROMETHEUS[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/plain\r\nConnection: Close\r\n\r\n"; + static const char HTTPOKPROMETHEUS[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/plain\r\nConnection: Close\r\n\r\n"; static const char HTTPOKJAVASCRIPT[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/javascript\r\nConnection: Close\r\n\r\n"; static const char HTTPOKCSS[] = "HTTP/1.1 200 Ok\r\nContent-Type: text/css\r\nConnection: Close\r\n\r\n"; static const char HTTPNOCONTENT[] = "HTTP/1.1 204 No content\r\nConnection: Close\r\n\r\n"; |