aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorjon2205 <jon2205@yandex-team.ru>2022-02-10 16:50:59 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:59 +0300
commitfa48a9aebc6cda36fdf7632883c934e1f262e71f (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp
parent1cbb079ecb3328b501da4e4bdb362ef2b91ad2bb (diff)
downloadydb-fa48a9aebc6cda36fdf7632883c934e1f262e71f.tar.gz
Restoring authorship annotation for <jon2205@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/monlib/counters/timer.h2
-rw-r--r--library/cpp/monlib/counters/timer_ut.cpp48
-rw-r--r--library/cpp/monlib/dynamic_counters/golovan_page.cpp130
-rw-r--r--library/cpp/monlib/dynamic_counters/golovan_page.h42
4 files changed, 111 insertions, 111 deletions
diff --git a/library/cpp/monlib/counters/timer.h b/library/cpp/monlib/counters/timer.h
index d64606b2a0..03dfb35337 100644
--- a/library/cpp/monlib/counters/timer.h
+++ b/library/cpp/monlib/counters/timer.h
@@ -166,7 +166,7 @@ namespace NMonitoring {
(*Callback_)(duration);
}
Timer_->RecordValue(duration);
- }
+ }
private:
TTimer* Timer_;
diff --git a/library/cpp/monlib/counters/timer_ut.cpp b/library/cpp/monlib/counters/timer_ut.cpp
index 207006fc3a..c5cd07e89d 100644
--- a/library/cpp/monlib/counters/timer_ut.cpp
+++ b/library/cpp/monlib/counters/timer_ut.cpp
@@ -5,17 +5,17 @@
using namespace NMonitoring;
using namespace std::literals::chrono_literals;
-class TCallback {
-public:
+class TCallback {
+public:
explicit TCallback(int value)
: Value_(value){};
- void operator()(std::chrono::high_resolution_clock::duration duration) {
- Value_ = duration.count();
- };
-
- int Value_;
-};
-
+ void operator()(std::chrono::high_resolution_clock::duration duration) {
+ Value_ = duration.count();
+ };
+
+ int Value_;
+};
+
Y_UNIT_TEST_SUITE(TTimerTest) {
Y_UNIT_TEST(RecordValue) {
TTimerNs timerNs(1ns, 1s);
@@ -62,20 +62,20 @@ Y_UNIT_TEST_SUITE(TTimerTest) {
UNIT_ASSERT(snapshot.Max > std::chrono::microseconds(10ms).count());
UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6);
}
-
+
Y_UNIT_TEST(TimerScopeWithCallback) {
- TCallback callback(0);
- TTimerUs timer(1us, 1000s);
- {
- TTimerScope<TTimerUs, TCallback> scope(&timer, &callback);
- Sleep(TDuration::MilliSeconds(10));
- }
- THistogramSnapshot snapshot;
- timer.TakeSnapshot(&snapshot);
-
- UNIT_ASSERT(snapshot.Min > std::chrono::microseconds(10ms).count());
- UNIT_ASSERT(snapshot.Max > std::chrono::microseconds(10ms).count());
- UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6);
- UNIT_ASSERT(callback.Value_ > std::chrono::microseconds(10ms).count());
- }
+ TCallback callback(0);
+ TTimerUs timer(1us, 1000s);
+ {
+ TTimerScope<TTimerUs, TCallback> scope(&timer, &callback);
+ Sleep(TDuration::MilliSeconds(10));
+ }
+ THistogramSnapshot snapshot;
+ timer.TakeSnapshot(&snapshot);
+
+ UNIT_ASSERT(snapshot.Min > std::chrono::microseconds(10ms).count());
+ UNIT_ASSERT(snapshot.Max > std::chrono::microseconds(10ms).count());
+ UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6);
+ UNIT_ASSERT(callback.Value_ > std::chrono::microseconds(10ms).count());
+ }
}
diff --git a/library/cpp/monlib/dynamic_counters/golovan_page.cpp b/library/cpp/monlib/dynamic_counters/golovan_page.cpp
index 2c658858c7..49cf2d39bb 100644
--- a/library/cpp/monlib/dynamic_counters/golovan_page.cpp
+++ b/library/cpp/monlib/dynamic_counters/golovan_page.cpp
@@ -1,79 +1,79 @@
#include "golovan_page.h"
-
+
#include <library/cpp/monlib/service/pages/templates.h>
-
-#include <util/string/split.h>
-#include <util/system/tls.h>
-
-using namespace NMonitoring;
-
-class TGolovanCountableConsumer: public ICountableConsumer {
-public:
- using TOutputCallback = std::function<void()>;
-
- TGolovanCountableConsumer(IOutputStream& out, TOutputCallback& OutputCallback)
- : out(out)
- {
- if (OutputCallback) {
- OutputCallback();
- }
-
- out << HTTPOKJSON << "[";
- FirstCounter = true;
- }
-
+
+#include <util/string/split.h>
+#include <util/system/tls.h>
+
+using namespace NMonitoring;
+
+class TGolovanCountableConsumer: public ICountableConsumer {
+public:
+ using TOutputCallback = std::function<void()>;
+
+ TGolovanCountableConsumer(IOutputStream& out, TOutputCallback& OutputCallback)
+ : out(out)
+ {
+ if (OutputCallback) {
+ OutputCallback();
+ }
+
+ out << HTTPOKJSON << "[";
+ FirstCounter = true;
+ }
+
void OnCounter(const TString&, const TString& value, const TCounterForPtr* counter) override {
- if (FirstCounter) {
- FirstCounter = false;
- } else {
- out << ",";
- }
-
- out << "[\"" << prefix + value;
- if (counter->ForDerivative()) {
+ if (FirstCounter) {
+ FirstCounter = false;
+ } else {
+ out << ",";
+ }
+
+ out << "[\"" << prefix + value;
+ if (counter->ForDerivative()) {
out << "_dmmm";
- } else {
- out << "_ahhh";
- }
-
- out << "\"," << counter->Val() << "]";
- }
-
+ } else {
+ out << "_ahhh";
+ }
+
+ out << "\"," << counter->Val() << "]";
+ }
+
void OnHistogram(const TString&, const TString&, IHistogramSnapshotPtr, bool) override {
}
void OnGroupBegin(const TString&, const TString& value, const TDynamicCounters*) override {
- prefix += value;
+ prefix += value;
if (!value.empty()) {
- prefix += "_";
- }
- }
-
+ prefix += "_";
+ }
+ }
+
void OnGroupEnd(const TString&, const TString&, const TDynamicCounters*) override {
- prefix = "";
- }
-
- void Flush() {
- out << "]";
- out.Flush();
- }
-
-private:
+ prefix = "";
+ }
+
+ void Flush() {
+ out << "]";
+ out.Flush();
+ }
+
+private:
IOutputStream& out;
- bool FirstCounter;
+ bool FirstCounter;
TString prefix;
-};
-
-TGolovanCountersPage::TGolovanCountersPage(const TString& path, TIntrusivePtr<NMonitoring::TDynamicCounters> counters,
- TOutputCallback outputCallback)
- : IMonPage(path)
- , Counters(counters)
- , OutputCallback(outputCallback)
-{
-}
-
+};
+
+TGolovanCountersPage::TGolovanCountersPage(const TString& path, TIntrusivePtr<NMonitoring::TDynamicCounters> counters,
+ TOutputCallback outputCallback)
+ : IMonPage(path)
+ , Counters(counters)
+ , OutputCallback(outputCallback)
+{
+}
+
void TGolovanCountersPage::Output(IMonHttpRequest& request) {
TGolovanCountableConsumer consumer(request.Output(), OutputCallback);
- Counters->Accept("", "", consumer);
- consumer.Flush();
-}
+ Counters->Accept("", "", consumer);
+ consumer.Flush();
+}
diff --git a/library/cpp/monlib/dynamic_counters/golovan_page.h b/library/cpp/monlib/dynamic_counters/golovan_page.h
index fe0877ad48..e1772c7734 100644
--- a/library/cpp/monlib/dynamic_counters/golovan_page.h
+++ b/library/cpp/monlib/dynamic_counters/golovan_page.h
@@ -1,25 +1,25 @@
-#pragma once
-
+#pragma once
+
#include "counters.h"
-
+
#include <library/cpp/monlib/service/pages/mon_page.h>
-
-#include <util/generic/ptr.h>
-
-#include <functional>
-
-// helper class to output json for Golovan.
-class TGolovanCountersPage: public NMonitoring::IMonPage {
-public:
- using TOutputCallback = std::function<void()>;
-
- const TIntrusivePtr<NMonitoring::TDynamicCounters> Counters;
-
- TGolovanCountersPage(const TString& path, TIntrusivePtr<NMonitoring::TDynamicCounters> counters,
- TOutputCallback outputCallback = nullptr);
-
+
+#include <util/generic/ptr.h>
+
+#include <functional>
+
+// helper class to output json for Golovan.
+class TGolovanCountersPage: public NMonitoring::IMonPage {
+public:
+ using TOutputCallback = std::function<void()>;
+
+ const TIntrusivePtr<NMonitoring::TDynamicCounters> Counters;
+
+ TGolovanCountersPage(const TString& path, TIntrusivePtr<NMonitoring::TDynamicCounters> counters,
+ TOutputCallback outputCallback = nullptr);
+
void Output(NMonitoring::IMonHttpRequest& request) override;
-private:
- TOutputCallback OutputCallback;
-};
+private:
+ TOutputCallback OutputCallback;
+};