aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib
diff options
context:
space:
mode:
authorprime <prime@yandex-team.ru>2022-02-10 16:46:00 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:00 +0300
commit3695a7cd42b74a4987d8d5a8f2e2443556998943 (patch)
treeee79ee9294a61ee00e647684b3700d0a87e102a3 /library/cpp/monlib
parent4d8b546b89b5afc08cf3667e176271c7ba935f33 (diff)
downloadydb-3695a7cd42b74a4987d8d5a8f2e2443556998943.tar.gz
Restoring authorship annotation for <prime@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib')
-rw-r--r--library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp36
-rw-r--r--library/cpp/monlib/encode/buffered/buffered_encoder_base.h2
-rw-r--r--library/cpp/monlib/encode/buffered/string_pool.cpp20
-rw-r--r--library/cpp/monlib/encode/buffered/string_pool.h2
-rw-r--r--library/cpp/monlib/encode/buffered/string_pool_ut.cpp8
-rw-r--r--library/cpp/monlib/encode/json/json_encoder.cpp10
-rw-r--r--library/cpp/monlib/encode/json/json_ut.cpp14
-rw-r--r--library/cpp/monlib/encode/json/ut/expected_buffered.json24
-rw-r--r--library/cpp/monlib/encode/spack/spack_v1_ut.cpp30
-rw-r--r--library/cpp/monlib/metrics/metric_consumer.cpp28
-rw-r--r--library/cpp/monlib/metrics/metric_consumer.h2
-rw-r--r--library/cpp/monlib/metrics/ya.make2
12 files changed, 89 insertions, 89 deletions
diff --git a/library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp b/library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp
index 87c832d642..3f18e42d6e 100644
--- a/library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp
+++ b/library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp
@@ -89,25 +89,25 @@ void TBufferedEncoderBase::OnLabel(TStringBuf name, TStringBuf value) {
labels->emplace_back(LabelNamesPool_.PutIfAbsent(name), LabelValuesPool_.PutIfAbsent(value));
}
-void TBufferedEncoderBase::OnLabel(ui32 name, ui32 value) {
- TPooledLabels* labels;
- if (State_ == TEncoderState::EState::METRIC_LABELS) {
- labels = &Metrics_.back().Labels;
- } else if (State_ == TEncoderState::EState::COMMON_LABELS) {
- labels = &CommonLabels_;
- } else {
- State_.ThrowInvalid("expected LABELS or COMMON_LABELS");
- }
-
- labels->emplace_back(LabelNamesPool_.GetByIndex(name), LabelValuesPool_.GetByIndex(value));
-}
-
+void TBufferedEncoderBase::OnLabel(ui32 name, ui32 value) {
+ TPooledLabels* labels;
+ if (State_ == TEncoderState::EState::METRIC_LABELS) {
+ labels = &Metrics_.back().Labels;
+ } else if (State_ == TEncoderState::EState::COMMON_LABELS) {
+ labels = &CommonLabels_;
+ } else {
+ State_.ThrowInvalid("expected LABELS or COMMON_LABELS");
+ }
+
+ labels->emplace_back(LabelNamesPool_.GetByIndex(name), LabelValuesPool_.GetByIndex(value));
+}
+
std::pair<ui32, ui32> TBufferedEncoderBase::PrepareLabel(TStringBuf name, TStringBuf value) {
- auto nameLabel = LabelNamesPool_.PutIfAbsent(name);
- auto valueLabel = LabelValuesPool_.PutIfAbsent(value);
- return std::make_pair(nameLabel->Index, valueLabel->Index);
-}
-
+ auto nameLabel = LabelNamesPool_.PutIfAbsent(name);
+ auto valueLabel = LabelValuesPool_.PutIfAbsent(value);
+ return std::make_pair(nameLabel->Index, valueLabel->Index);
+}
+
void TBufferedEncoderBase::OnDouble(TInstant time, double value) {
State_.Expect(TEncoderState::EState::METRIC);
TMetric& metric = Metrics_.back();
diff --git a/library/cpp/monlib/encode/buffered/buffered_encoder_base.h b/library/cpp/monlib/encode/buffered/buffered_encoder_base.h
index fe3714e58f..165d92203e 100644
--- a/library/cpp/monlib/encode/buffered/buffered_encoder_base.h
+++ b/library/cpp/monlib/encode/buffered/buffered_encoder_base.h
@@ -26,7 +26,7 @@ public:
void OnLabelsBegin() override;
void OnLabelsEnd() override;
void OnLabel(TStringBuf name, TStringBuf value) override;
- void OnLabel(ui32 name, ui32 value) override;
+ void OnLabel(ui32 name, ui32 value) override;
std::pair<ui32, ui32> PrepareLabel(TStringBuf name, TStringBuf value) override;
void OnDouble(TInstant time, double value) override;
diff --git a/library/cpp/monlib/encode/buffered/string_pool.cpp b/library/cpp/monlib/encode/buffered/string_pool.cpp
index b4c7988ba3..d819e11ae7 100644
--- a/library/cpp/monlib/encode/buffered/string_pool.cpp
+++ b/library/cpp/monlib/encode/buffered/string_pool.cpp
@@ -10,8 +10,8 @@ namespace NMonitoring {
auto [it, isInserted] = StrMap_.try_emplace(str, Max<ui32>(), 0);
if (isInserted) {
BytesSize_ += str.size();
- it->second.Index = StrVector_.size();
- StrVector_.emplace_back(it->first, &it->second);
+ it->second.Index = StrVector_.size();
+ StrVector_.emplace_back(it->first, &it->second);
}
TValue* value = &it->second;
@@ -19,10 +19,10 @@ namespace NMonitoring {
return value;
}
- const TStringPoolBuilder::TValue* TStringPoolBuilder::GetByIndex(ui32 index) const {
- return StrVector_.at(index).second;
- }
-
+ const TStringPoolBuilder::TValue* TStringPoolBuilder::GetByIndex(ui32 index) const {
+ return StrVector_.at(index).second;
+ }
+
TStringPoolBuilder& TStringPoolBuilder::Build() {
if (RequiresSorting_) {
// sort in reversed order
@@ -30,10 +30,10 @@ namespace NMonitoring {
return a.second->Frequency > b.second->Frequency;
});
- ui32 i = 0;
- for (auto& value : StrVector_) {
- value.second->Index = i++;
- }
+ ui32 i = 0;
+ for (auto& value : StrVector_) {
+ value.second->Index = i++;
+ }
}
IsBuilt_ = true;
diff --git a/library/cpp/monlib/encode/buffered/string_pool.h b/library/cpp/monlib/encode/buffered/string_pool.h
index 00e5644608..e216cff388 100644
--- a/library/cpp/monlib/encode/buffered/string_pool.h
+++ b/library/cpp/monlib/encode/buffered/string_pool.h
@@ -22,7 +22,7 @@ namespace NMonitoring {
public:
const TValue* PutIfAbsent(TStringBuf str);
- const TValue* GetByIndex(ui32 index) const;
+ const TValue* GetByIndex(ui32 index) const;
/// Determines whether pool must be sorted by value frequencies
TStringPoolBuilder& SetSorted(bool sorted) {
diff --git a/library/cpp/monlib/encode/buffered/string_pool_ut.cpp b/library/cpp/monlib/encode/buffered/string_pool_ut.cpp
index 9fc3421d0b..21839ccb47 100644
--- a/library/cpp/monlib/encode/buffered/string_pool_ut.cpp
+++ b/library/cpp/monlib/encode/buffered/string_pool_ut.cpp
@@ -16,10 +16,10 @@ Y_UNIT_TEST_SUITE(TStringPoolTest) {
UNIT_ASSERT(h2 == h3);
UNIT_ASSERT_VALUES_EQUAL(h1->Frequency, 1);
- UNIT_ASSERT_VALUES_EQUAL(h1->Index, 0);
+ UNIT_ASSERT_VALUES_EQUAL(h1->Index, 0);
UNIT_ASSERT_VALUES_EQUAL(h2->Frequency, 2);
- UNIT_ASSERT_VALUES_EQUAL(h2->Index, 1);
+ UNIT_ASSERT_VALUES_EQUAL(h2->Index, 1);
UNIT_ASSERT_VALUES_EQUAL(strPool.BytesSize(), 6);
UNIT_ASSERT_VALUES_EQUAL(strPool.Count(), 2);
@@ -49,8 +49,8 @@ Y_UNIT_TEST_SUITE(TStringPoolTest) {
Y_UNIT_TEST(ForEach) {
TStringPoolBuilder strPool;
- strPool.SetSorted(true);
-
+ strPool.SetSorted(true);
+
strPool.PutIfAbsent("one");
strPool.PutIfAbsent("two");
strPool.PutIfAbsent("two");
diff --git a/library/cpp/monlib/encode/json/json_encoder.cpp b/library/cpp/monlib/encode/json/json_encoder.cpp
index 20d2bb6283..e376cbb564 100644
--- a/library/cpp/monlib/encode/json/json_encoder.cpp
+++ b/library/cpp/monlib/encode/json/json_encoder.cpp
@@ -440,11 +440,11 @@ namespace NMonitoring {
EmptyLabels_ = false;
}
- void OnLabel(ui32 name, ui32 value) override {
- TBufferedEncoderBase::OnLabel(name, value);
- EmptyLabels_ = false;
- }
-
+ void OnLabel(ui32 name, ui32 value) override {
+ TBufferedEncoderBase::OnLabel(name, value);
+ EmptyLabels_ = false;
+ }
+
void OnLabelsEnd() override {
TBufferedEncoderBase::OnLabelsEnd();
Y_ENSURE(!EmptyLabels_, "Labels cannot be empty");
diff --git a/library/cpp/monlib/encode/json/json_ut.cpp b/library/cpp/monlib/encode/json/json_ut.cpp
index 09e7909289..281c114a23 100644
--- a/library/cpp/monlib/encode/json/json_ut.cpp
+++ b/library/cpp/monlib/encode/json/json_ut.cpp
@@ -225,14 +225,14 @@ Y_UNIT_TEST_SUITE(TJsonTest) {
e->Close();
json += "\n";
- auto parseJson = [] (auto buf) {
- NJson::TJsonValue value;
- NJson::ReadJsonTree(buf, &value, true);
- return value;
- };
-
+ auto parseJson = [] (auto buf) {
+ NJson::TJsonValue value;
+ NJson::ReadJsonTree(buf, &value, true);
+ return value;
+ };
+
const auto expectedJson = NResource::Find(expectedResourceKey);
- UNIT_ASSERT_EQUAL(parseJson(json), parseJson(expectedJson));
+ UNIT_ASSERT_EQUAL(parseJson(json), parseJson(expectedJson));
};
check(false, false, "/expected.json");
diff --git a/library/cpp/monlib/encode/json/ut/expected_buffered.json b/library/cpp/monlib/encode/json/ut/expected_buffered.json
index 9a6a1d6201..0441766a68 100644
--- a/library/cpp/monlib/encode/json/ut/expected_buffered.json
+++ b/library/cpp/monlib/encode/json/ut/expected_buffered.json
@@ -10,8 +10,8 @@
"kind":"COUNTER",
"labels":
{
- "labels":"l1",
- "metric":"single"
+ "labels":"l1",
+ "metric":"single"
},
"ts":1509843723,
"value":17
@@ -20,8 +20,8 @@
"kind":"RATE",
"labels":
{
- "labels":"l2",
- "metric":"single"
+ "labels":"l2",
+ "metric":"single"
},
"ts":1509843723,
"value":17
@@ -30,8 +30,8 @@
"kind":"GAUGE",
"labels":
{
- "labels":"l3",
- "metric":"single"
+ "labels":"l3",
+ "metric":"single"
},
"ts":1509843723,
"value":3.14
@@ -40,8 +40,8 @@
"kind":"IGAUGE",
"labels":
{
- "labels":"l4",
- "metric":"single_igauge"
+ "labels":"l4",
+ "metric":"single_igauge"
},
"ts":1509843723,
"value":42
@@ -50,8 +50,8 @@
"kind":"GAUGE",
"labels":
{
- "labels":"l5",
- "metric":"multiple"
+ "labels":"l5",
+ "metric":"multiple"
},
"timeseries":
[
@@ -73,8 +73,8 @@
"kind":"COUNTER",
"labels":
{
- "labels":"l6",
- "metric":"multiple"
+ "labels":"l6",
+ "metric":"multiple"
},
"timeseries":
[
diff --git a/library/cpp/monlib/encode/spack/spack_v1_ut.cpp b/library/cpp/monlib/encode/spack/spack_v1_ut.cpp
index fe778eb7e0..7802f7c5e9 100644
--- a/library/cpp/monlib/encode/spack/spack_v1_ut.cpp
+++ b/library/cpp/monlib/encode/spack/spack_v1_ut.cpp
@@ -78,18 +78,18 @@ Y_UNIT_TEST_SUITE(TSpackTest) {
ui8 expectedStringPools[] = {
0x6e, 0x61, 0x6d, 0x65, 0x00, // "name\0"
0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x00, // "project\0"
- 0x73, 0x6f, 0x6c, 0x6f, 0x6d, 0x6f, 0x6e, 0x00, // "solomon\0"
- 0x71, 0x31, 0x00, // "q1\0"
- 0x71, 0x32, 0x00, // "q2\0"
- 0x71, 0x33, 0x00, // "q3\0"
- 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x00, // "answer\0"
+ 0x73, 0x6f, 0x6c, 0x6f, 0x6d, 0x6f, 0x6e, 0x00, // "solomon\0"
+ 0x71, 0x31, 0x00, // "q1\0"
+ 0x71, 0x32, 0x00, // "q2\0"
+ 0x71, 0x33, 0x00, // "q3\0"
+ 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x00, // "answer\0"
0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, // "responseTimeMillis\0"
0x54, 0x69, 0x6d, 0x65, 0x4d, 0x69, 0x6c, 0x6c,
0x69, 0x73, 0x00,
0x62, 0x79, 0x74, 0x65, 0x73, 0x00, // "bytes\0"
- 0x74, 0x65, 0x6D, 0x70, 0x65, 0x72, 0x61, 0x74, // "temperature\0"
- 0x75, 0x72, 0x65, 0x00,
- 0x6d, 0x73, 0x00, // "ms\0"
+ 0x74, 0x65, 0x6D, 0x70, 0x65, 0x72, 0x61, 0x74, // "temperature\0"
+ 0x75, 0x72, 0x65, 0x00,
+ 0x6d, 0x73, 0x00, // "ms\0"
};
ui8 expectedCommonTime[] = {
@@ -99,7 +99,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {
ui8 expectedCommonLabels[] = {
0x01, // common labels count (varint)
0x01, // label name index (varint)
- 0x00, // label value index (varint)
+ 0x00, // label value index (varint)
};
ui8 expectedMetric1[] = {
@@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {
0x00, // flags (fixed ui8)
0x01, // metric labels count (varint)
0x00, // label name index (varint)
- 0x01, // label value index (varint)
+ 0x01, // label value index (varint)
};
ui8 expectedMetric2[] = {
@@ -115,7 +115,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {
0x00, // flags (fixed ui8)
0x01, // metric labels count (varint)
0x00, // label name index (varint)
- 0x02, // label value index (varint)
+ 0x02, // label value index (varint)
0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // value (fixed ui64)
};
@@ -147,7 +147,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {
0x00, // flags (fixed ui8)
0x01, // metric labels count (varint)
0x00, // label name index (varint)
- 0x05, // label value index (varint)
+ 0x05, // label value index (varint)
0x0b, 0x63, 0xfe, 0x59, // time in seconds (fixed ui32)
0x06, // histogram buckets count (varint)
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // histogram bucket bounds (array of fixed ui64)
@@ -169,7 +169,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {
0x00, // flags (fixed ui8)
0x01, // metric labels count (varint)
0x00, // label name index (varint)
- 0x05, // label value index (varint)
+ 0x05, // label value index (varint)
0x0b, 0x63, 0xfe, 0x59, // time in seconds (fixed ui32)
0x06, // histogram buckets count (varint)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, // histogram bucket bounds (array of doubles)
@@ -201,7 +201,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {
0x00, // flags (fixed ui8)
0x01, // metric labels count (varint)
0x00, // label name index (varint)
- 0x07, // label value index (varint)
+ 0x07, // label value index (varint)
0x0b, 0x63, 0xfe, 0x59, // time in seconds (fixed ui32)
0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // count (fixed ui64)
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x24, 0x40, // sum (fixed double)
@@ -755,7 +755,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {
e->OnMetricBegin(EMetricType::COUNTER);
{
e->OnLabelsBegin();
- e->OnLabel("project", "solomon");
+ e->OnLabel("project", "solomon");
e->OnLabel("s", "temperature");
e->OnLabelsEnd();
}
diff --git a/library/cpp/monlib/metrics/metric_consumer.cpp b/library/cpp/monlib/metrics/metric_consumer.cpp
index 121ee368f0..c2155f4b5b 100644
--- a/library/cpp/monlib/metrics/metric_consumer.cpp
+++ b/library/cpp/monlib/metrics/metric_consumer.cpp
@@ -1,15 +1,15 @@
-#include "metric_consumer.h"
-
-#include <util/system/yassert.h>
-
-namespace NMonitoring {
- void IMetricConsumer::OnLabel(ui32 name, ui32 value) {
- Y_UNUSED(name, value);
- Y_ENSURE(false, "Not implemented");
- }
-
+#include "metric_consumer.h"
+
+#include <util/system/yassert.h>
+
+namespace NMonitoring {
+ void IMetricConsumer::OnLabel(ui32 name, ui32 value) {
+ Y_UNUSED(name, value);
+ Y_ENSURE(false, "Not implemented");
+ }
+
std::pair<ui32, ui32> IMetricConsumer::PrepareLabel(TStringBuf name, TStringBuf value) {
- Y_UNUSED(name, value);
- Y_ENSURE(false, "Not implemented");
- }
-}
+ Y_UNUSED(name, value);
+ Y_ENSURE(false, "Not implemented");
+ }
+}
diff --git a/library/cpp/monlib/metrics/metric_consumer.h b/library/cpp/monlib/metrics/metric_consumer.h
index f7a727585a..74352103fa 100644
--- a/library/cpp/monlib/metrics/metric_consumer.h
+++ b/library/cpp/monlib/metrics/metric_consumer.h
@@ -23,7 +23,7 @@ namespace NMonitoring {
virtual void OnLabelsBegin() = 0;
virtual void OnLabelsEnd() = 0;
virtual void OnLabel(TStringBuf name, TStringBuf value) = 0;
- virtual void OnLabel(ui32 name, ui32 value);
+ virtual void OnLabel(ui32 name, ui32 value);
virtual std::pair<ui32, ui32> PrepareLabel(TStringBuf name, TStringBuf value);
virtual void OnDouble(TInstant time, double value) = 0;
diff --git a/library/cpp/monlib/metrics/ya.make b/library/cpp/monlib/metrics/ya.make
index 0e1fa143f9..a2ecf50df0 100644
--- a/library/cpp/monlib/metrics/ya.make
+++ b/library/cpp/monlib/metrics/ya.make
@@ -17,7 +17,7 @@ SRCS(
log_histogram_snapshot.cpp
labels.cpp
metric_registry.cpp
- metric_consumer.cpp
+ metric_consumer.cpp
metric_type.cpp
metric_value.cpp
summary_snapshot.cpp