aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrorewillo <rorewillo@yandex-team.ru>2022-02-10 16:50:59 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:59 +0300
commit708f3525bad4968571f23f3f942ac910ec3f57d3 (patch)
tree1f328d3adc165401bd9fa2957ceffdf3ca69375a
parenta235c43ca4e121284b828a6bbef65acd5978a2bf (diff)
downloadydb-708f3525bad4968571f23f3f942ac910ec3f57d3.tar.gz
Restoring authorship annotation for <rorewillo@yandex-team.ru>. Commit 1 of 2.
-rw-r--r--library/cpp/monlib/encode/json/json.h2
-rw-r--r--library/cpp/monlib/encode/json/json_decoder.cpp30
-rw-r--r--library/cpp/monlib/encode/json/json_decoder_ut.cpp4
-rw-r--r--library/cpp/monlib/encode/json/json_ut.cpp46
-rw-r--r--library/cpp/monlib/encode/json/ut/named_metrics.json44
-rw-r--r--library/cpp/monlib/encode/json/ut/ya.make2
-rw-r--r--library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp2
7 files changed, 65 insertions, 65 deletions
diff --git a/library/cpp/monlib/encode/json/json.h b/library/cpp/monlib/encode/json/json.h
index 21530f20c3..13d84f1855 100644
--- a/library/cpp/monlib/encode/json/json.h
+++ b/library/cpp/monlib/encode/json/json.h
@@ -24,6 +24,6 @@ namespace NMonitoring {
int indentation = 0,
TStringBuf metricNameLabel = "name");
- void DecodeJson(TStringBuf data, IMetricConsumer* c, TStringBuf metricNameLabel = "name");
+ void DecodeJson(TStringBuf data, IMetricConsumer* c, TStringBuf metricNameLabel = "name");
}
diff --git a/library/cpp/monlib/encode/json/json_decoder.cpp b/library/cpp/monlib/encode/json/json_decoder.cpp
index d44ff5fd28..66546cdb46 100644
--- a/library/cpp/monlib/encode/json/json_decoder.cpp
+++ b/library/cpp/monlib/encode/json/json_decoder.cpp
@@ -439,7 +439,7 @@ class TDecoderJson final: public NJson::TJsonCallbacks {
METRICS_ARRAY,
METRIC_OBJECT,
- METRIC_NAME,
+ METRIC_NAME,
METRIC_LABELS,
METRIC_TYPE,
METRIC_MODE, // TODO: must be deleted
@@ -482,10 +482,10 @@ class TDecoderJson final: public NJson::TJsonCallbacks {
};
public:
- TDecoderJson(TStringBuf data, IHaltableMetricConsumer* metricConsumer, TStringBuf metricNameLabel)
+ TDecoderJson(TStringBuf data, IHaltableMetricConsumer* metricConsumer, TStringBuf metricNameLabel)
: Data_(data)
, MetricConsumer_(metricConsumer)
- , MetricNameLabel_(metricNameLabel)
+ , MetricNameLabel_(metricNameLabel)
{
}
@@ -725,12 +725,12 @@ if (Y_UNLIKELY(!(CONDITION))) { \
LastMetric_.Labels.Add(LastLabelName_, TString{value});
break;
- case TState::METRIC_NAME:
- PARSE_ENSURE(!value.empty(), "empty metric name");
- LastMetric_.Labels.Add(MetricNameLabel_, TString{value});
- State_.ToPrev();
- break;
-
+ case TState::METRIC_NAME:
+ PARSE_ENSURE(!value.empty(), "empty metric name");
+ LastMetric_.Labels.Add(MetricNameLabel_, TString{value});
+ State_.ToPrev();
+ break;
+
case TState::COMMON_TS:
MetricConsumer_->OnCommonTime(TInstant::ParseIso8601(value));
State_.ToPrev();
@@ -831,8 +831,8 @@ if (Y_UNLIKELY(!(CONDITION))) { \
case TState::METRIC_OBJECT:
if (key == TStringBuf("labels")) {
State_.ToNext(TState::METRIC_LABELS);
- } else if (key == TStringBuf("name")) {
- State_.ToNext(TState::METRIC_NAME);
+ } else if (key == TStringBuf("name")) {
+ State_.ToNext(TState::METRIC_NAME);
} else if (key == TStringBuf("ts")) {
PARSE_ENSURE(!LastMetric_.SeenTimeseries,
"mixed timeseries and ts attributes");
@@ -1129,7 +1129,7 @@ if (Y_UNLIKELY(!(CONDITION))) { \
private:
TStringBuf Data_;
IHaltableMetricConsumer* MetricConsumer_;
- TString MetricNameLabel_;
+ TString MetricNameLabel_;
TState State_;
TString LastLabelName_;
TMetricCollector LastMetric_;
@@ -1139,11 +1139,11 @@ private:
} // namespace
-void DecodeJson(TStringBuf data, IMetricConsumer* c, TStringBuf metricNameLabel) {
+void DecodeJson(TStringBuf data, IMetricConsumer* c, TStringBuf metricNameLabel) {
TCommonPartsCollector commonPartsCollector;
{
TMemoryInput memIn(data);
- TDecoderJson decoder(data, &commonPartsCollector, metricNameLabel);
+ TDecoderJson decoder(data, &commonPartsCollector, metricNameLabel);
// no need to check a return value. If there is an error, a TJsonDecodeError is thrown
NJson::ReadJson(&memIn, &decoder);
}
@@ -1151,7 +1151,7 @@ void DecodeJson(TStringBuf data, IMetricConsumer* c, TStringBuf metricNameLabel)
TCommonPartsProxy commonPartsProxy(std::move(commonPartsCollector.CommonParts()), c);
{
TMemoryInput memIn(data);
- TDecoderJson decoder(data, &commonPartsProxy, metricNameLabel);
+ TDecoderJson decoder(data, &commonPartsProxy, metricNameLabel);
// no need to check a return value. If there is an error, a TJsonDecodeError is thrown
NJson::ReadJson(&memIn, &decoder);
}
diff --git a/library/cpp/monlib/encode/json/json_decoder_ut.cpp b/library/cpp/monlib/encode/json/json_decoder_ut.cpp
index 4464e1d26a..06b34e3ce9 100644
--- a/library/cpp/monlib/encode/json/json_decoder_ut.cpp
+++ b/library/cpp/monlib/encode/json/json_decoder_ut.cpp
@@ -73,10 +73,10 @@ void ValidateMetrics(const TVector<TMetricData>& metrics) {
UNIT_ASSERT_VALUES_EQUAL((*m.Values)[0].GetValue().AsDouble(), 123);
}
-void CheckCommonPartsCollector(TString data, bool shouldBeStopped, bool checkLabels = true, bool checkTs = true, TStringBuf metricNameLabel = "name") {
+void CheckCommonPartsCollector(TString data, bool shouldBeStopped, bool checkLabels = true, bool checkTs = true, TStringBuf metricNameLabel = "name") {
TCommonPartsCollector commonPartsCollector;
TMemoryInput memIn(data);
- TDecoderJson decoder(data, &commonPartsCollector, metricNameLabel);
+ TDecoderJson decoder(data, &commonPartsCollector, metricNameLabel);
bool isOk{false};
UNIT_ASSERT_NO_EXCEPTION(isOk = NJson::ReadJson(&memIn, &decoder));
diff --git a/library/cpp/monlib/encode/json/json_ut.cpp b/library/cpp/monlib/encode/json/json_ut.cpp
index 09e7909289..29320d2938 100644
--- a/library/cpp/monlib/encode/json/json_ut.cpp
+++ b/library/cpp/monlib/encode/json/json_ut.cpp
@@ -1264,27 +1264,27 @@ Y_UNIT_TEST_SUITE(TJsonTest) {
UNIT_ASSERT_EXCEPTION(DecodeJson(input, e.Get()), yexception);
}
- Y_UNIT_TEST(DecodeNamedMetrics) {
- NProto::TMultiSamplesList samples;
- {
- IMetricEncoderPtr e = EncoderProtobuf(&samples);
-
- TString metricsJson = NResource::Find("/named_metrics.json");
- DecodeJson(metricsJson, e.Get(), "sensor");
- }
-
- UNIT_ASSERT_VALUES_EQUAL(samples.SamplesSize(), 2);
- {
- const NProto::TMultiSample& s = samples.GetSamples(0);
- UNIT_ASSERT_VALUES_EQUAL(s.LabelsSize(), 1);
- AssertLabelEqual(s.GetLabels(0), "sensor", "Memory");
- }
- {
- const NProto::TMultiSample& s = samples.GetSamples(1);
- UNIT_ASSERT_VALUES_EQUAL(s.LabelsSize(), 2);
- AssertLabelEqual(s.GetLabels(0), "sensor", "QueueSize");
- AssertLabelEqual(s.GetLabels(1), "export", "Oxygen");
- }
- }
-
+ Y_UNIT_TEST(DecodeNamedMetrics) {
+ NProto::TMultiSamplesList samples;
+ {
+ IMetricEncoderPtr e = EncoderProtobuf(&samples);
+
+ TString metricsJson = NResource::Find("/named_metrics.json");
+ DecodeJson(metricsJson, e.Get(), "sensor");
+ }
+
+ UNIT_ASSERT_VALUES_EQUAL(samples.SamplesSize(), 2);
+ {
+ const NProto::TMultiSample& s = samples.GetSamples(0);
+ UNIT_ASSERT_VALUES_EQUAL(s.LabelsSize(), 1);
+ AssertLabelEqual(s.GetLabels(0), "sensor", "Memory");
+ }
+ {
+ const NProto::TMultiSample& s = samples.GetSamples(1);
+ UNIT_ASSERT_VALUES_EQUAL(s.LabelsSize(), 2);
+ AssertLabelEqual(s.GetLabels(0), "sensor", "QueueSize");
+ AssertLabelEqual(s.GetLabels(1), "export", "Oxygen");
+ }
+ }
+
}
diff --git a/library/cpp/monlib/encode/json/ut/named_metrics.json b/library/cpp/monlib/encode/json/ut/named_metrics.json
index 98f93e8c39..462f1fdb91 100644
--- a/library/cpp/monlib/encode/json/ut/named_metrics.json
+++ b/library/cpp/monlib/encode/json/ut/named_metrics.json
@@ -1,22 +1,22 @@
-{
- "labels": {
- "project": "solomon",
- "cluster": "prod-sas",
- "service": "stockpile"
- },
- "metrics": [
- {
- "type": "DGAUGE",
- "name": "Memory",
- "value": 1
- },
- {
- "type": "DGAUGE",
- "name": "QueueSize",
- "labels": {
- "export": "Oxygen"
- },
- "value": 10
- }
- ]
-}
+{
+ "labels": {
+ "project": "solomon",
+ "cluster": "prod-sas",
+ "service": "stockpile"
+ },
+ "metrics": [
+ {
+ "type": "DGAUGE",
+ "name": "Memory",
+ "value": 1
+ },
+ {
+ "type": "DGAUGE",
+ "name": "QueueSize",
+ "labels": {
+ "export": "Oxygen"
+ },
+ "value": 10
+ }
+ ]
+}
diff --git a/library/cpp/monlib/encode/json/ut/ya.make b/library/cpp/monlib/encode/json/ut/ya.make
index e50c4f4903..1443b0797f 100644
--- a/library/cpp/monlib/encode/json/ut/ya.make
+++ b/library/cpp/monlib/encode/json/ut/ya.make
@@ -25,7 +25,7 @@ RESOURCE(
int_gauge.json /int_gauge.json
sensors.json /sensors.json
metrics.json /metrics.json
- named_metrics.json /named_metrics.json
+ named_metrics.json /named_metrics.json
test_decode_to_encode.json /test_decode_to_encode.json
crash.json /crash.json
hist_crash.json /hist_crash.json
diff --git a/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp b/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp
index 7e81357dbd..f12ea5e123 100644
--- a/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp
+++ b/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp
@@ -518,7 +518,7 @@ namespace NMonitoring {
void ConsumeLabels(TStringBuf name, const TLabelsMap& labels) {
Y_PARSER_ENSURE(labels.count(MetricNameLabel_) == 0,
"label name '" << MetricNameLabel_ <<
- "' is reserved, but is used with metric: " << name << LabelsToStr(labels));
+ "' is reserved, but is used with metric: " << name << LabelsToStr(labels));
Consumer_->OnLabelsBegin();
Consumer_->OnLabel(MetricNameLabel_, TString(name)); // TODO: remove this string allocation