aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorIgor Makunin <igor.makunin@gmail.com>2022-02-10 16:49:35 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:35 +0300
commitc617191a3b33c0f5e1be6390361dbe540775d158 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library
parentf7a438035f19b364b5479caf536990e82b174f38 (diff)
downloadydb-c617191a3b33c0f5e1be6390361dbe540775d158.tar.gz
Restoring authorship annotation for Igor Makunin <igor.makunin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library')
-rw-r--r--library/cpp/http/server/response_ut.cpp26
-rw-r--r--library/cpp/monlib/counters/histogram.cpp6
-rw-r--r--library/cpp/monlib/counters/histogram.h2
-rw-r--r--library/cpp/monlib/counters/histogram_ut.cpp4
-rw-r--r--library/cpp/monlib/counters/timer.h2
-rw-r--r--library/cpp/monlib/metrics/metric.h8
-rw-r--r--library/cpp/monlib/metrics/timer.h56
-rw-r--r--library/cpp/monlib/metrics/timer_ut.cpp206
-rw-r--r--library/cpp/monlib/metrics/ut/ya.make2
9 files changed, 156 insertions, 156 deletions
diff --git a/library/cpp/http/server/response_ut.cpp b/library/cpp/http/server/response_ut.cpp
index 8569839db9..73e2112ad3 100644
--- a/library/cpp/http/server/response_ut.cpp
+++ b/library/cpp/http/server/response_ut.cpp
@@ -126,17 +126,17 @@ Y_UNIT_TEST_SUITE(TestHttpResponse) {
UNIT_ASSERT_EQUAL(&resp, &resp.SetContent("some stuff"));
UNIT_ASSERT_EQUAL(&resp, &resp.SetContent("some other stuff").SetContentType("text/plain"));
}
-
- Y_UNIT_TEST(TestSetContentType) {
- const char* EXPECTED = "HTTP/1.1 200 Ok\r\n"
- "Content-Type: text/xml\r\n"
- "Content-Length: 28\r\n"
- "\r\n"
- "<xml><tag value=\"1\" /></xml>";
- THttpResponse resp;
- resp.SetContent("<xml><tag value=\"1\" /></xml>")
- .SetContentType("application/json")
- .SetContentType("text/xml");
- UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), EXPECTED);
- }
+
+ Y_UNIT_TEST(TestSetContentType) {
+ const char* EXPECTED = "HTTP/1.1 200 Ok\r\n"
+ "Content-Type: text/xml\r\n"
+ "Content-Length: 28\r\n"
+ "\r\n"
+ "<xml><tag value=\"1\" /></xml>";
+ THttpResponse resp;
+ resp.SetContent("<xml><tag value=\"1\" /></xml>")
+ .SetContentType("application/json")
+ .SetContentType("text/xml");
+ UNIT_ASSERT_STRINGS_EQUAL(ToString(resp), EXPECTED);
+ }
}
diff --git a/library/cpp/monlib/counters/histogram.cpp b/library/cpp/monlib/counters/histogram.cpp
index 41d8a19372..46cf4e6ec8 100644
--- a/library/cpp/monlib/counters/histogram.cpp
+++ b/library/cpp/monlib/counters/histogram.cpp
@@ -12,8 +12,8 @@ namespace NMonitoring {
<< ", 95%: " << Percentile95
<< ", 98%: " << Percentile98
<< ", 99%: " << Percentile99
- << ", 99.9%: " << Percentile999
- << ", count: " << TotalCount;
+ << ", 99.9%: " << Percentile999
+ << ", count: " << TotalCount;
}
void THdrHistogram::TakeSnaphot(THistogramSnapshot* snapshot) {
@@ -30,7 +30,7 @@ namespace NMonitoring {
snapshot->Percentile98 = Data_.GetValueAtPercentile(98.0);
snapshot->Percentile99 = Data_.GetValueAtPercentile(99.0);
snapshot->Percentile999 = Data_.GetValueAtPercentile(99.9);
- snapshot->TotalCount = Data_.GetTotalCount();
+ snapshot->TotalCount = Data_.GetTotalCount();
// cleanup histogram data
Data_.Reset();
diff --git a/library/cpp/monlib/counters/histogram.h b/library/cpp/monlib/counters/histogram.h
index ef4d50d369..96361b0023 100644
--- a/library/cpp/monlib/counters/histogram.h
+++ b/library/cpp/monlib/counters/histogram.h
@@ -21,7 +21,7 @@ namespace NMonitoring {
i64 Percentile98;
i64 Percentile99;
i64 Percentile999;
- i64 TotalCount;
+ i64 TotalCount;
void Print(IOutputStream* out) const;
};
diff --git a/library/cpp/monlib/counters/histogram_ut.cpp b/library/cpp/monlib/counters/histogram_ut.cpp
index c45a6237ac..5a0800505a 100644
--- a/library/cpp/monlib/counters/histogram_ut.cpp
+++ b/library/cpp/monlib/counters/histogram_ut.cpp
@@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(THistorgamTest) {
UNIT_ASSERT_EQUAL(snapshot.Percentile98, 5);
UNIT_ASSERT_EQUAL(snapshot.Percentile99, 5);
UNIT_ASSERT_EQUAL(snapshot.Percentile999, 5);
-
- UNIT_ASSERT_EQUAL(snapshot.TotalCount, 14);
+
+ UNIT_ASSERT_EQUAL(snapshot.TotalCount, 14);
}
}
diff --git a/library/cpp/monlib/counters/timer.h b/library/cpp/monlib/counters/timer.h
index 87bf3c720b..03dfb35337 100644
--- a/library/cpp/monlib/counters/timer.h
+++ b/library/cpp/monlib/counters/timer.h
@@ -111,7 +111,7 @@ namespace NMonitoring {
template <typename TFunc>
void Measure(TFunc&& fn) {
using TClock = std::chrono::high_resolution_clock;
-
+
auto start = TClock::now();
Y_SCOPE_EXIT(this, start) {
diff --git a/library/cpp/monlib/metrics/metric.h b/library/cpp/monlib/metrics/metric.h
index fe97d2b475..b8ce12d753 100644
--- a/library/cpp/monlib/metrics/metric.h
+++ b/library/cpp/monlib/metrics/metric.h
@@ -371,13 +371,13 @@ namespace NMonitoring {
}
void Accept(TInstant time, IMetricConsumer* consumer) const override {
- consumer->OnHistogram(time, TakeSnapshot());
+ consumer->OnHistogram(time, TakeSnapshot());
}
IHistogramSnapshotPtr TakeSnapshot() const override {
- return Collector_->Snapshot();
- }
-
+ return Collector_->Snapshot();
+ }
+
void Reset() override {
Collector_->Reset();
}
diff --git a/library/cpp/monlib/metrics/timer.h b/library/cpp/monlib/metrics/timer.h
index b45cc0bc9b..5c4e26e37b 100644
--- a/library/cpp/monlib/metrics/timer.h
+++ b/library/cpp/monlib/metrics/timer.h
@@ -1,29 +1,29 @@
-#pragma once
-
+#pragma once
+
#include "metric.h"
-
+
#include <util/generic/typetraits.h>
-#include <chrono>
-
-
-namespace NMonitoring {
-
- /**
- * A timing scope to record elapsed time since creation.
- */
+#include <chrono>
+
+
+namespace NMonitoring {
+
+ /**
+ * A timing scope to record elapsed time since creation.
+ */
template <typename TMetric,
- typename Resolution = std::chrono::milliseconds,
- typename Clock = std::chrono::high_resolution_clock>
+ typename Resolution = std::chrono::milliseconds,
+ typename Clock = std::chrono::high_resolution_clock>
class TMetricTimerScope {
- public:
+ public:
explicit TMetricTimerScope(TMetric* metric)
: Metric_(metric)
- , StartTime_(Clock::now())
- {
+ , StartTime_(Clock::now())
+ {
Y_ENSURE(Metric_);
- }
-
+ }
+
TMetricTimerScope(TMetricTimerScope&) = delete;
TMetricTimerScope& operator=(const TMetricTimerScope&) = delete;
@@ -45,7 +45,7 @@ namespace NMonitoring {
return;
}
- auto duration = std::chrono::duration_cast<Resolution>(Clock::now() - StartTime_).count();
+ auto duration = std::chrono::duration_cast<Resolution>(Clock::now() - StartTime_).count();
if constexpr (std::is_same<TMetric, TGauge>::value) {
Metric_->Set(duration);
} else if constexpr (std::is_same<TMetric, TIntGauge>::value) {
@@ -56,13 +56,13 @@ namespace NMonitoring {
Metric_->Add(duration);
} else if constexpr (std::is_same<TMetric, THistogram>::value) {
Metric_->Record(duration);
- } else {
+ } else {
static_assert(TDependentFalse<TMetric>, "Not supported metric type");
- }
+ }
Metric_ = nullptr;
- }
-
+ }
+
~TMetricTimerScope() {
if (Metric_ == nullptr) {
return;
@@ -71,11 +71,11 @@ namespace NMonitoring {
Record();
}
- private:
+ private:
TMetric* Metric_{nullptr};
- typename Clock::time_point StartTime_;
- };
-
+ typename Clock::time_point StartTime_;
+ };
+
/**
* @brief A class that is supposed to use to measure execution time of an asynchronuous operation.
*
@@ -124,4 +124,4 @@ namespace NMonitoring {
TFutureFriendlyTimer<TMetric> FutureTimer(TMetric* metric) {
return TFutureFriendlyTimer<TMetric>{metric};
}
-}
+}
diff --git a/library/cpp/monlib/metrics/timer_ut.cpp b/library/cpp/monlib/metrics/timer_ut.cpp
index 9827edcda0..c244a8c9e1 100644
--- a/library/cpp/monlib/metrics/timer_ut.cpp
+++ b/library/cpp/monlib/metrics/timer_ut.cpp
@@ -1,120 +1,120 @@
-#include "timer.h"
-
+#include "timer.h"
+
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/threading/future/async.h>
#include <library/cpp/threading/future/future.h>
-
-using namespace NMonitoring;
+
+using namespace NMonitoring;
using namespace NThreading;
-
-Y_UNIT_TEST_SUITE(TTimerTest) {
-
- using namespace std::chrono;
-
- struct TTestClock {
- using time_point = time_point<high_resolution_clock>;
-
- static time_point TimePoint;
-
- static time_point now() {
- return TimePoint;
- }
- };
-
- TTestClock::time_point TTestClock::TimePoint;
-
-
- Y_UNIT_TEST(Gauge) {
- TTestClock::TimePoint = TTestClock::time_point::min();
-
- TGauge gauge(0);
- {
+
+Y_UNIT_TEST_SUITE(TTimerTest) {
+
+ using namespace std::chrono;
+
+ struct TTestClock {
+ using time_point = time_point<high_resolution_clock>;
+
+ static time_point TimePoint;
+
+ static time_point now() {
+ return TimePoint;
+ }
+ };
+
+ TTestClock::time_point TTestClock::TimePoint;
+
+
+ Y_UNIT_TEST(Gauge) {
+ TTestClock::TimePoint = TTestClock::time_point::min();
+
+ TGauge gauge(0);
+ {
TMetricTimerScope<TGauge, milliseconds, TTestClock> t{&gauge};
- TTestClock::TimePoint += milliseconds(10);
- }
- UNIT_ASSERT_EQUAL(10, gauge.Get());
-
- {
+ TTestClock::TimePoint += milliseconds(10);
+ }
+ UNIT_ASSERT_EQUAL(10, gauge.Get());
+
+ {
TMetricTimerScope<TGauge, milliseconds, TTestClock> t{&gauge};
- TTestClock::TimePoint += milliseconds(20);
- }
- UNIT_ASSERT_EQUAL(20, gauge.Get());
- }
-
- Y_UNIT_TEST(IntGauge) {
- TTestClock::TimePoint = TTestClock::time_point::min();
-
- TIntGauge gauge(0);
- {
+ TTestClock::TimePoint += milliseconds(20);
+ }
+ UNIT_ASSERT_EQUAL(20, gauge.Get());
+ }
+
+ Y_UNIT_TEST(IntGauge) {
+ TTestClock::TimePoint = TTestClock::time_point::min();
+
+ TIntGauge gauge(0);
+ {
TMetricTimerScope<TIntGauge, milliseconds, TTestClock> t{&gauge};
- TTestClock::TimePoint += milliseconds(10);
- }
- UNIT_ASSERT_EQUAL(10, gauge.Get());
-
- {
+ TTestClock::TimePoint += milliseconds(10);
+ }
+ UNIT_ASSERT_EQUAL(10, gauge.Get());
+
+ {
TMetricTimerScope<TIntGauge, milliseconds, TTestClock> t{&gauge};
- TTestClock::TimePoint += milliseconds(20);
- }
- UNIT_ASSERT_EQUAL(20, gauge.Get());
- }
-
- Y_UNIT_TEST(CounterNew) {
- TTestClock::TimePoint = TTestClock::time_point::min();
-
+ TTestClock::TimePoint += milliseconds(20);
+ }
+ UNIT_ASSERT_EQUAL(20, gauge.Get());
+ }
+
+ Y_UNIT_TEST(CounterNew) {
+ TTestClock::TimePoint = TTestClock::time_point::min();
+
TCounter counter(0);
- {
+ {
TMetricTimerScope<TCounter, milliseconds, TTestClock> t{&counter};
- TTestClock::TimePoint += milliseconds(10);
- }
- UNIT_ASSERT_EQUAL(10, counter.Get());
-
- {
+ TTestClock::TimePoint += milliseconds(10);
+ }
+ UNIT_ASSERT_EQUAL(10, counter.Get());
+
+ {
TMetricTimerScope<TCounter, milliseconds, TTestClock> t{&counter};
- TTestClock::TimePoint += milliseconds(20);
- }
- UNIT_ASSERT_EQUAL(30, counter.Get());
- }
-
- Y_UNIT_TEST(Rate) {
- TTestClock::TimePoint = TTestClock::time_point::min();
-
- TRate rate(0);
- {
+ TTestClock::TimePoint += milliseconds(20);
+ }
+ UNIT_ASSERT_EQUAL(30, counter.Get());
+ }
+
+ Y_UNIT_TEST(Rate) {
+ TTestClock::TimePoint = TTestClock::time_point::min();
+
+ TRate rate(0);
+ {
TMetricTimerScope<TRate, milliseconds, TTestClock> t{&rate};
- TTestClock::TimePoint += milliseconds(10);
- }
- UNIT_ASSERT_EQUAL(10, rate.Get());
-
- {
+ TTestClock::TimePoint += milliseconds(10);
+ }
+ UNIT_ASSERT_EQUAL(10, rate.Get());
+
+ {
TMetricTimerScope<TRate, milliseconds, TTestClock> t{&rate};
- TTestClock::TimePoint += milliseconds(20);
- }
- UNIT_ASSERT_EQUAL(30, rate.Get());
- }
-
- Y_UNIT_TEST(Histogram) {
- TTestClock::TimePoint = TTestClock::time_point::min();
-
- auto assertHistogram = [](const TVector<ui64>& expected, IHistogramSnapshotPtr snapshot) {
- UNIT_ASSERT_EQUAL(expected.size(), snapshot->Count());
- for (size_t i = 0; i < expected.size(); ++i) {
- UNIT_ASSERT_EQUAL(expected[i], snapshot->Value(i));
- }
- };
-
- THistogram histogram(ExplicitHistogram({10, 20, 30}), true);
- {
+ TTestClock::TimePoint += milliseconds(20);
+ }
+ UNIT_ASSERT_EQUAL(30, rate.Get());
+ }
+
+ Y_UNIT_TEST(Histogram) {
+ TTestClock::TimePoint = TTestClock::time_point::min();
+
+ auto assertHistogram = [](const TVector<ui64>& expected, IHistogramSnapshotPtr snapshot) {
+ UNIT_ASSERT_EQUAL(expected.size(), snapshot->Count());
+ for (size_t i = 0; i < expected.size(); ++i) {
+ UNIT_ASSERT_EQUAL(expected[i], snapshot->Value(i));
+ }
+ };
+
+ THistogram histogram(ExplicitHistogram({10, 20, 30}), true);
+ {
TMetricTimerScope<THistogram, milliseconds, TTestClock> t{&histogram};
- TTestClock::TimePoint += milliseconds(5);
- }
- assertHistogram({1, 0, 0, 0}, histogram.TakeSnapshot());
-
- {
+ TTestClock::TimePoint += milliseconds(5);
+ }
+ assertHistogram({1, 0, 0, 0}, histogram.TakeSnapshot());
+
+ {
TMetricTimerScope<THistogram, milliseconds, TTestClock> t{&histogram};
- TTestClock::TimePoint += milliseconds(15);
- }
- assertHistogram({1, 1, 0, 0}, histogram.TakeSnapshot());
- }
+ TTestClock::TimePoint += milliseconds(15);
+ }
+ assertHistogram({1, 1, 0, 0}, histogram.TakeSnapshot());
+ }
Y_UNIT_TEST(Moving) {
TTestClock::TimePoint = TTestClock::time_point::min();
@@ -154,4 +154,4 @@ Y_UNIT_TEST_SUITE(TTimerTest) {
UNIT_ASSERT_EQUAL(counter.Get(), 5);
}
-}
+}
diff --git a/library/cpp/monlib/metrics/ut/ya.make b/library/cpp/monlib/metrics/ut/ya.make
index 698920571f..aec9974fbd 100644
--- a/library/cpp/monlib/metrics/ut/ya.make
+++ b/library/cpp/monlib/metrics/ut/ya.make
@@ -15,7 +15,7 @@ SRCS(
metric_sub_registry_ut.cpp
metric_value_ut.cpp
summary_collector_ut.cpp
- timer_ut.cpp
+ timer_ut.cpp
)
RESOURCE(