aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/encode/json
diff options
context:
space:
mode:
authorgusev-p <gusev-p@yandex-team.ru>2022-02-10 16:47:20 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:20 +0300
commit1715700d00b30399d3648be821fd585ae552365e (patch)
tree6857a59158ea36e56d87fb32fbb8e44673c0ca0f /library/cpp/monlib/encode/json
parentb23c1d7a8015c2006a148fd93b84cdeb0aee17a3 (diff)
downloadydb-1715700d00b30399d3648be821fd585ae552365e.tar.gz
Restoring authorship annotation for <gusev-p@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/encode/json')
-rw-r--r--library/cpp/monlib/encode/json/json.h16
-rw-r--r--library/cpp/monlib/encode/json/json_decoder.cpp2
-rw-r--r--library/cpp/monlib/encode/json/json_decoder_ut.cpp112
-rw-r--r--library/cpp/monlib/encode/json/json_encoder.cpp200
-rw-r--r--library/cpp/monlib/encode/json/json_ut.cpp446
-rw-r--r--library/cpp/monlib/encode/json/ut/expected.json30
-rw-r--r--library/cpp/monlib/encode/json/ut/expected_buffered.json24
-rw-r--r--library/cpp/monlib/encode/json/ut/expected_cloud.json74
-rw-r--r--library/cpp/monlib/encode/json/ut/expected_cloud_buffered.json184
-rw-r--r--library/cpp/monlib/encode/json/ut/ya.make6
10 files changed, 547 insertions, 547 deletions
diff --git a/library/cpp/monlib/encode/json/json.h b/library/cpp/monlib/encode/json/json.h
index 21530f20c3..f6968c0016 100644
--- a/library/cpp/monlib/encode/json/json.h
+++ b/library/cpp/monlib/encode/json/json.h
@@ -16,14 +16,14 @@ namespace NMonitoring {
/// Buffered encoder will merge series with same labels into one.
IMetricEncoderPtr BufferedEncoderJson(IOutputStream* out, int indentation = 0);
- IMetricEncoderPtr EncoderCloudJson(IOutputStream* out,
- int indentation = 0,
- TStringBuf metricNameLabel = "name");
-
- IMetricEncoderPtr BufferedEncoderCloudJson(IOutputStream* out,
- int indentation = 0,
- TStringBuf metricNameLabel = "name");
-
+ IMetricEncoderPtr EncoderCloudJson(IOutputStream* out,
+ int indentation = 0,
+ TStringBuf metricNameLabel = "name");
+
+ IMetricEncoderPtr BufferedEncoderCloudJson(IOutputStream* out,
+ int indentation = 0,
+ 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..8420b93aab 100644
--- a/library/cpp/monlib/encode/json/json_decoder.cpp
+++ b/library/cpp/monlib/encode/json/json_decoder.cpp
@@ -52,7 +52,7 @@ public:
Bounds_.clear();
Values_.clear();
- InfPresented_ = false;
+ InfPresented_ = false;
return snapshot;
}
diff --git a/library/cpp/monlib/encode/json/json_decoder_ut.cpp b/library/cpp/monlib/encode/json/json_decoder_ut.cpp
index 4464e1d26a..52c34e4f37 100644
--- a/library/cpp/monlib/encode/json/json_decoder_ut.cpp
+++ b/library/cpp/monlib/encode/json/json_decoder_ut.cpp
@@ -120,60 +120,60 @@ Y_UNIT_TEST_SUITE(TJsonDecoderTest) {
ValidateCommonParts(std::move(commonParts), true, true);
ValidateMetrics(collector.Metrics);
}
-
- Y_UNIT_TEST(CanParseHistogramsWithInf) {
- const char* metricsData = R"({
-"metrics":
- [
- {
- "hist": {
- "bounds": [
- 10
- ],
- "buckets": [
- 11
- ],
- "inf": 12
- },
- "name":"s1",
- "type": "HIST_RATE"
- },
- {
- "hist": {
- "bounds": [
- 20
- ],
- "buckets": [
- 21
- ]
- },
- "name":"s2",
- "type":"HIST_RATE"
- }
- ]
-})";
- TCollectingConsumer consumer(false);
- DecodeJson(metricsData, &consumer);
-
- UNIT_ASSERT_VALUES_EQUAL(consumer.Metrics.size(), 2);
- {
- const auto& m = consumer.Metrics[0];
- UNIT_ASSERT_VALUES_EQUAL(m.Kind, EMetricType::HIST_RATE);
- UNIT_ASSERT_VALUES_EQUAL(m.Values->Size(), 1);
- const auto* histogram = (*m.Values)[0].GetValue().AsHistogram();
- UNIT_ASSERT_VALUES_EQUAL(histogram->Count(), 2);
- UNIT_ASSERT_VALUES_EQUAL(histogram->UpperBound(1), Max<TBucketBound>());
- UNIT_ASSERT_VALUES_EQUAL(histogram->Value(0), 11);
- UNIT_ASSERT_VALUES_EQUAL(histogram->Value(1), 12);
- }
- {
- const auto& m = consumer.Metrics[1];
- UNIT_ASSERT_VALUES_EQUAL(m.Kind, EMetricType::HIST_RATE);
- UNIT_ASSERT_VALUES_EQUAL(m.Values->Size(), 1);
- const auto* histogram = (*m.Values)[0].GetValue().AsHistogram();
- UNIT_ASSERT_VALUES_EQUAL(histogram->Count(), 1);
- UNIT_ASSERT_VALUES_EQUAL(histogram->UpperBound(0), 20);
- UNIT_ASSERT_VALUES_EQUAL(histogram->Value(0), 21);
- }
- }
+
+ Y_UNIT_TEST(CanParseHistogramsWithInf) {
+ const char* metricsData = R"({
+"metrics":
+ [
+ {
+ "hist": {
+ "bounds": [
+ 10
+ ],
+ "buckets": [
+ 11
+ ],
+ "inf": 12
+ },
+ "name":"s1",
+ "type": "HIST_RATE"
+ },
+ {
+ "hist": {
+ "bounds": [
+ 20
+ ],
+ "buckets": [
+ 21
+ ]
+ },
+ "name":"s2",
+ "type":"HIST_RATE"
+ }
+ ]
+})";
+ TCollectingConsumer consumer(false);
+ DecodeJson(metricsData, &consumer);
+
+ UNIT_ASSERT_VALUES_EQUAL(consumer.Metrics.size(), 2);
+ {
+ const auto& m = consumer.Metrics[0];
+ UNIT_ASSERT_VALUES_EQUAL(m.Kind, EMetricType::HIST_RATE);
+ UNIT_ASSERT_VALUES_EQUAL(m.Values->Size(), 1);
+ const auto* histogram = (*m.Values)[0].GetValue().AsHistogram();
+ UNIT_ASSERT_VALUES_EQUAL(histogram->Count(), 2);
+ UNIT_ASSERT_VALUES_EQUAL(histogram->UpperBound(1), Max<TBucketBound>());
+ UNIT_ASSERT_VALUES_EQUAL(histogram->Value(0), 11);
+ UNIT_ASSERT_VALUES_EQUAL(histogram->Value(1), 12);
+ }
+ {
+ const auto& m = consumer.Metrics[1];
+ UNIT_ASSERT_VALUES_EQUAL(m.Kind, EMetricType::HIST_RATE);
+ UNIT_ASSERT_VALUES_EQUAL(m.Values->Size(), 1);
+ const auto* histogram = (*m.Values)[0].GetValue().AsHistogram();
+ UNIT_ASSERT_VALUES_EQUAL(histogram->Count(), 1);
+ UNIT_ASSERT_VALUES_EQUAL(histogram->UpperBound(0), 20);
+ UNIT_ASSERT_VALUES_EQUAL(histogram->Value(0), 21);
+ }
+ }
}
diff --git a/library/cpp/monlib/encode/json/json_encoder.cpp b/library/cpp/monlib/encode/json/json_encoder.cpp
index 20d2bb6283..fb14ffdf07 100644
--- a/library/cpp/monlib/encode/json/json_encoder.cpp
+++ b/library/cpp/monlib/encode/json/json_encoder.cpp
@@ -14,21 +14,21 @@
namespace NMonitoring {
namespace {
- enum class EJsonStyle {
- Solomon,
- Cloud
- };
-
+ enum class EJsonStyle {
+ Solomon,
+ Cloud
+ };
+
///////////////////////////////////////////////////////////////////////
// TJsonWriter
///////////////////////////////////////////////////////////////////////
class TJsonWriter {
public:
- TJsonWriter(IOutputStream* out, int indentation, EJsonStyle style, TStringBuf metricNameLabel)
+ TJsonWriter(IOutputStream* out, int indentation, EJsonStyle style, TStringBuf metricNameLabel)
: Buf_(NJsonWriter::HEM_UNSAFE, out)
- , Style_(style)
- , MetricNameLabel_(metricNameLabel)
- , CurrentMetricName_()
+ , Style_(style)
+ , MetricNameLabel_(metricNameLabel)
+ , CurrentMetricName_()
{
Buf_.SetIndentSpaces(indentation);
Buf_.SetWriteNanAsString();
@@ -37,11 +37,11 @@ namespace NMonitoring {
void WriteTime(TInstant time) {
if (time != TInstant::Zero()) {
Buf_.WriteKey(TStringBuf("ts"));
- if (Style_ == EJsonStyle::Solomon) {
- Buf_.WriteULongLong(time.Seconds());
- } else {
- Buf_.WriteString(time.ToString());
- }
+ if (Style_ == EJsonStyle::Solomon) {
+ Buf_.WriteULongLong(time.Seconds());
+ } else {
+ Buf_.WriteString(time.ToString());
+ }
}
}
@@ -61,8 +61,8 @@ namespace NMonitoring {
}
void WriteValue(IHistogramSnapshot* s) {
- Y_ENSURE(Style_ == EJsonStyle::Solomon);
-
+ Y_ENSURE(Style_ == EJsonStyle::Solomon);
+
Buf_.WriteKey(TStringBuf("hist"));
Buf_.BeginObject();
if (ui32 count = s->Count()) {
@@ -94,8 +94,8 @@ namespace NMonitoring {
}
void WriteValue(ISummaryDoubleSnapshot* s) {
- Y_ENSURE(Style_ == EJsonStyle::Solomon);
-
+ Y_ENSURE(Style_ == EJsonStyle::Solomon);
+
Buf_.WriteKey(TStringBuf("summary"));
Buf_.BeginObject();
@@ -118,8 +118,8 @@ namespace NMonitoring {
}
void WriteValue(TLogHistogramSnapshot* s) {
- Y_ENSURE(Style_ == EJsonStyle::Solomon);
-
+ Y_ENSURE(Style_ == EJsonStyle::Solomon);
+
Buf_.WriteKey(TStringBuf("log_hist"));
Buf_.BeginObject();
@@ -169,64 +169,64 @@ namespace NMonitoring {
break;
case EMetricValueType::UNKNOWN:
- ythrow yexception() << "unknown metric value type";
+ ythrow yexception() << "unknown metric value type";
}
}
void WriteLabel(TStringBuf name, TStringBuf value) {
Y_ENSURE(IsUtf(name), "label name is not valid UTF-8 string");
Y_ENSURE(IsUtf(value), "label value is not valid UTF-8 string");
- if (Style_ == EJsonStyle::Cloud && name == MetricNameLabel_) {
- CurrentMetricName_ = value;
- } else {
- Buf_.WriteKey(name);
- Buf_.WriteString(value);
- }
- }
-
- void WriteMetricType(EMetricType type) {
- if (Style_ == EJsonStyle::Cloud) {
- Buf_.WriteKey("type");
- Buf_.WriteString(MetricTypeToCloudStr(type));
- } else {
- Buf_.WriteKey("kind");
- Buf_.WriteString(MetricTypeToStr(type));
- }
- }
-
- void WriteName() {
- if (Style_ != EJsonStyle::Cloud) {
- return;
- }
- if (CurrentMetricName_.Empty()) {
- ythrow yexception() << "label '" << MetricNameLabel_ << "' is not defined";
- }
- Buf_.WriteKey("name");
- Buf_.WriteString(CurrentMetricName_);
- CurrentMetricName_.clear();
- }
-
- private:
- static TStringBuf MetricTypeToCloudStr(EMetricType type) {
- switch (type) {
- case EMetricType::GAUGE:
- return TStringBuf("DGAUGE");
- case EMetricType::COUNTER:
- return TStringBuf("COUNTER");
- case EMetricType::RATE:
- return TStringBuf("RATE");
- case EMetricType::IGAUGE:
- return TStringBuf("IGAUGE");
- default:
- ythrow yexception() << "metric type '" << type << "' is not supported by cloud json format";
- }
- }
-
+ if (Style_ == EJsonStyle::Cloud && name == MetricNameLabel_) {
+ CurrentMetricName_ = value;
+ } else {
+ Buf_.WriteKey(name);
+ Buf_.WriteString(value);
+ }
+ }
+
+ void WriteMetricType(EMetricType type) {
+ if (Style_ == EJsonStyle::Cloud) {
+ Buf_.WriteKey("type");
+ Buf_.WriteString(MetricTypeToCloudStr(type));
+ } else {
+ Buf_.WriteKey("kind");
+ Buf_.WriteString(MetricTypeToStr(type));
+ }
+ }
+
+ void WriteName() {
+ if (Style_ != EJsonStyle::Cloud) {
+ return;
+ }
+ if (CurrentMetricName_.Empty()) {
+ ythrow yexception() << "label '" << MetricNameLabel_ << "' is not defined";
+ }
+ Buf_.WriteKey("name");
+ Buf_.WriteString(CurrentMetricName_);
+ CurrentMetricName_.clear();
+ }
+
+ private:
+ static TStringBuf MetricTypeToCloudStr(EMetricType type) {
+ switch (type) {
+ case EMetricType::GAUGE:
+ return TStringBuf("DGAUGE");
+ case EMetricType::COUNTER:
+ return TStringBuf("COUNTER");
+ case EMetricType::RATE:
+ return TStringBuf("RATE");
+ case EMetricType::IGAUGE:
+ return TStringBuf("IGAUGE");
+ default:
+ ythrow yexception() << "metric type '" << type << "' is not supported by cloud json format";
+ }
+ }
+
protected:
NJsonWriter::TBuf Buf_;
- EJsonStyle Style_;
- TString MetricNameLabel_;
- TString CurrentMetricName_;
+ EJsonStyle Style_;
+ TString MetricNameLabel_;
+ TString CurrentMetricName_;
};
///////////////////////////////////////////////////////////////////////
@@ -234,8 +234,8 @@ namespace NMonitoring {
///////////////////////////////////////////////////////////////////////
class TEncoderJson final: public IMetricEncoder, public TJsonWriter {
public:
- TEncoderJson(IOutputStream* out, int indentation, EJsonStyle style, TStringBuf metricNameLabel)
- : TJsonWriter{out, indentation, style, metricNameLabel}
+ TEncoderJson(IOutputStream* out, int indentation, EJsonStyle style, TStringBuf metricNameLabel)
+ : TJsonWriter{out, indentation, style, metricNameLabel}
{
}
@@ -267,11 +267,11 @@ namespace NMonitoring {
State_.Switch(TEncoderState::EState::ROOT, TEncoderState::EState::METRIC);
if (Buf_.KeyExpected()) {
// first metric, so open metrics array
- Buf_.WriteKey(TStringBuf(Style_ == EJsonStyle::Solomon ? "sensors" : "metrics"));
+ Buf_.WriteKey(TStringBuf(Style_ == EJsonStyle::Solomon ? "sensors" : "metrics"));
Buf_.BeginList();
}
Buf_.BeginObject();
- WriteMetricType(type);
+ WriteMetricType(type);
}
void OnMetricEnd() override {
@@ -300,7 +300,7 @@ namespace NMonitoring {
}
if (State_ == TEncoderState::EState::ROOT) {
State_ = TEncoderState::EState::COMMON_LABELS;
- Buf_.WriteKey(TStringBuf(Style_ == EJsonStyle::Solomon ? "commonLabels" : "labels"));
+ Buf_.WriteKey(TStringBuf(Style_ == EJsonStyle::Solomon ? "commonLabels" : "labels"));
} else if (State_ == TEncoderState::EState::METRIC) {
State_ = TEncoderState::EState::METRIC_LABELS;
Buf_.WriteKey(TStringBuf("labels"));
@@ -323,9 +323,9 @@ namespace NMonitoring {
Y_ENSURE(!EmptyLabels_, "Labels cannot be empty");
Buf_.EndObject();
- if (State_ == TEncoderState::EState::METRIC) {
- WriteName();
- }
+ if (State_ == TEncoderState::EState::METRIC) {
+ WriteName();
+ }
}
void OnLabel(TStringBuf name, TStringBuf value) override {
@@ -420,8 +420,8 @@ namespace NMonitoring {
///////////////////////////////////////////////////////////////////////
class TBufferedJsonEncoder : public TBufferedEncoderBase, public TJsonWriter {
public:
- TBufferedJsonEncoder(IOutputStream* out, int indentation, EJsonStyle style, TStringBuf metricNameLabel)
- : TJsonWriter{out, indentation, style, metricNameLabel}
+ TBufferedJsonEncoder(IOutputStream* out, int indentation, EJsonStyle style, TStringBuf metricNameLabel)
+ : TJsonWriter{out, indentation, style, metricNameLabel}
{
MetricsMergingMode_ = EMetricsMergingMode::MERGE_METRICS;
}
@@ -464,12 +464,12 @@ namespace NMonitoring {
WriteTime(CommonTime_);
if (CommonLabels_.size() > 0) {
- Buf_.WriteKey(TStringBuf(Style_ == EJsonStyle::Solomon ? "commonLabels": "labels"));
- WriteLabels(CommonLabels_, true);
+ Buf_.WriteKey(TStringBuf(Style_ == EJsonStyle::Solomon ? "commonLabels": "labels"));
+ WriteLabels(CommonLabels_, true);
}
if (Metrics_.size() > 0) {
- Buf_.WriteKey(TStringBuf(Style_ == EJsonStyle::Solomon ? "sensors" : "metrics"));
+ Buf_.WriteKey(TStringBuf(Style_ == EJsonStyle::Solomon ? "sensors" : "metrics"));
WriteMetrics();
}
@@ -488,10 +488,10 @@ namespace NMonitoring {
void WriteMetric(TMetric& metric) {
Buf_.BeginObject();
- WriteMetricType(metric.MetricType);
+ WriteMetricType(metric.MetricType);
Buf_.WriteKey(TStringBuf("labels"));
- WriteLabels(metric.Labels, false);
+ WriteLabels(metric.Labels, false);
metric.TimeSeries.SortByTs();
if (metric.TimeSeries.Size() == 1) {
@@ -515,7 +515,7 @@ namespace NMonitoring {
Buf_.EndObject();
}
- void WriteLabels(const TPooledLabels& labels, bool isCommon) {
+ void WriteLabels(const TPooledLabels& labels, bool isCommon) {
Buf_.BeginObject();
for (auto i = 0u; i < labels.size(); ++i) {
@@ -526,10 +526,10 @@ namespace NMonitoring {
}
Buf_.EndObject();
-
- if (!isCommon) {
- WriteName();
- }
+
+ if (!isCommon) {
+ WriteName();
+ }
}
private:
@@ -539,18 +539,18 @@ namespace NMonitoring {
}
IMetricEncoderPtr EncoderJson(IOutputStream* out, int indentation) {
- return MakeHolder<TEncoderJson>(out, indentation, EJsonStyle::Solomon, "");
+ return MakeHolder<TEncoderJson>(out, indentation, EJsonStyle::Solomon, "");
}
IMetricEncoderPtr BufferedEncoderJson(IOutputStream* out, int indentation) {
- return MakeHolder<TBufferedJsonEncoder>(out, indentation, EJsonStyle::Solomon, "");
- }
-
- IMetricEncoderPtr EncoderCloudJson(IOutputStream* out, int indentation, TStringBuf metricNameLabel) {
- return MakeHolder<TEncoderJson>(out, indentation, EJsonStyle::Cloud, metricNameLabel);
- }
-
- IMetricEncoderPtr BufferedEncoderCloudJson(IOutputStream* out, int indentation, TStringBuf metricNameLabel) {
- return MakeHolder<TBufferedJsonEncoder>(out, indentation, EJsonStyle::Cloud, metricNameLabel);
+ return MakeHolder<TBufferedJsonEncoder>(out, indentation, EJsonStyle::Solomon, "");
}
+
+ IMetricEncoderPtr EncoderCloudJson(IOutputStream* out, int indentation, TStringBuf metricNameLabel) {
+ return MakeHolder<TEncoderJson>(out, indentation, EJsonStyle::Cloud, metricNameLabel);
+ }
+
+ IMetricEncoderPtr BufferedEncoderCloudJson(IOutputStream* out, int indentation, TStringBuf metricNameLabel) {
+ return MakeHolder<TBufferedJsonEncoder>(out, indentation, EJsonStyle::Cloud, metricNameLabel);
+ }
}
diff --git a/library/cpp/monlib/encode/json/json_ut.cpp b/library/cpp/monlib/encode/json/json_ut.cpp
index 09e7909289..9bd38e5fc5 100644
--- a/library/cpp/monlib/encode/json/json_ut.cpp
+++ b/library/cpp/monlib/encode/json/json_ut.cpp
@@ -8,7 +8,7 @@
#include <library/cpp/testing/unittest/registar.h>
#include <util/stream/str.h>
-#include <util/string/builder.h>
+#include <util/string/builder.h>
#include <limits>
@@ -136,171 +136,171 @@ Y_UNIT_TEST_SUITE(TJsonTest) {
const TInstant now = TInstant::ParseIso8601Deprecated("2017-11-05T01:02:03Z");
Y_UNIT_TEST(Encode) {
- auto check = [](bool cloud, bool buffered, TStringBuf expectedResourceKey) {
- TString json;
- TStringOutput out(json);
- auto e = cloud
- ? (buffered ? BufferedEncoderCloudJson(&out, 2, "metric") : EncoderCloudJson(&out, 2, "metric"))
- : (buffered ? BufferedEncoderJson(&out, 2) : EncoderJson(&out, 2));
- e->OnStreamBegin();
- { // common time
- e->OnCommonTime(TInstant::Seconds(1500000000));
+ auto check = [](bool cloud, bool buffered, TStringBuf expectedResourceKey) {
+ TString json;
+ TStringOutput out(json);
+ auto e = cloud
+ ? (buffered ? BufferedEncoderCloudJson(&out, 2, "metric") : EncoderCloudJson(&out, 2, "metric"))
+ : (buffered ? BufferedEncoderJson(&out, 2) : EncoderJson(&out, 2));
+ e->OnStreamBegin();
+ { // common time
+ e->OnCommonTime(TInstant::Seconds(1500000000));
}
- { // common labels
+ { // common labels
e->OnLabelsBegin();
- e->OnLabel("project", "solomon");
+ e->OnLabel("project", "solomon");
e->OnLabelsEnd();
}
- { // metric #1
- e->OnMetricBegin(EMetricType::COUNTER);
- {
- e->OnLabelsBegin();
- e->OnLabel("metric", "single");
- e->OnLabel("labels", "l1");
- e->OnLabelsEnd();
- }
- e->OnUint64(now, 17);
- e->OnMetricEnd();
- }
- { // metric #2
- e->OnMetricBegin(EMetricType::RATE);
- {
- e->OnLabelsBegin();
- e->OnLabel("metric", "single");
- e->OnLabel("labels", "l2");
- e->OnLabelsEnd();
- }
- e->OnUint64(now, 17);
- e->OnMetricEnd();
- }
- { // metric #3
- e->OnMetricBegin(EMetricType::GAUGE);
- e->OnDouble(now, 3.14);
- {
- e->OnLabelsBegin();
- e->OnLabel("metric", "single");
- e->OnLabel("labels", "l3");
- e->OnLabelsEnd();
- }
- e->OnMetricEnd();
- }
- { // metric #4
- e->OnMetricBegin(EMetricType::IGAUGE);
- e->OnInt64(now, 42);
- {
- e->OnLabelsBegin();
- e->OnLabel("metric", "single_igauge");
- e->OnLabel("labels", "l4");
- e->OnLabelsEnd();
- }
- e->OnMetricEnd();
+ { // metric #1
+ e->OnMetricBegin(EMetricType::COUNTER);
+ {
+ e->OnLabelsBegin();
+ e->OnLabel("metric", "single");
+ e->OnLabel("labels", "l1");
+ e->OnLabelsEnd();
+ }
+ e->OnUint64(now, 17);
+ e->OnMetricEnd();
}
- { // metric #5
- e->OnMetricBegin(EMetricType::GAUGE);
- {
- e->OnLabelsBegin();
- e->OnLabel("metric", "multiple");
- e->OnLabel("labels", "l5");
- e->OnLabelsEnd();
- }
- e->OnDouble(now, std::numeric_limits<double>::quiet_NaN());
- e->OnDouble(now + TDuration::Seconds(15), std::numeric_limits<double>::infinity());
- e->OnDouble(now + TDuration::Seconds(30), -std::numeric_limits<double>::infinity());
- e->OnMetricEnd();
+ { // metric #2
+ e->OnMetricBegin(EMetricType::RATE);
+ {
+ e->OnLabelsBegin();
+ e->OnLabel("metric", "single");
+ e->OnLabel("labels", "l2");
+ e->OnLabelsEnd();
+ }
+ e->OnUint64(now, 17);
+ e->OnMetricEnd();
}
-
- { // metric #6
- e->OnMetricBegin(EMetricType::COUNTER);
- e->OnUint64(now, 1337);
- e->OnUint64(now + TDuration::Seconds(15), 1338);
- {
- e->OnLabelsBegin();
- e->OnLabel("metric", "multiple");
- e->OnLabel("labels", "l6");
- e->OnLabelsEnd();
- }
- e->OnMetricEnd();
- }
- e->OnStreamEnd();
- e->Close();
- json += "\n";
-
+ { // metric #3
+ e->OnMetricBegin(EMetricType::GAUGE);
+ e->OnDouble(now, 3.14);
+ {
+ e->OnLabelsBegin();
+ e->OnLabel("metric", "single");
+ e->OnLabel("labels", "l3");
+ e->OnLabelsEnd();
+ }
+ e->OnMetricEnd();
+ }
+ { // metric #4
+ e->OnMetricBegin(EMetricType::IGAUGE);
+ e->OnInt64(now, 42);
+ {
+ e->OnLabelsBegin();
+ e->OnLabel("metric", "single_igauge");
+ e->OnLabel("labels", "l4");
+ e->OnLabelsEnd();
+ }
+ e->OnMetricEnd();
+ }
+ { // metric #5
+ e->OnMetricBegin(EMetricType::GAUGE);
+ {
+ e->OnLabelsBegin();
+ e->OnLabel("metric", "multiple");
+ e->OnLabel("labels", "l5");
+ e->OnLabelsEnd();
+ }
+ e->OnDouble(now, std::numeric_limits<double>::quiet_NaN());
+ e->OnDouble(now + TDuration::Seconds(15), std::numeric_limits<double>::infinity());
+ e->OnDouble(now + TDuration::Seconds(30), -std::numeric_limits<double>::infinity());
+ e->OnMetricEnd();
+ }
+
+ { // metric #6
+ e->OnMetricBegin(EMetricType::COUNTER);
+ e->OnUint64(now, 1337);
+ e->OnUint64(now + TDuration::Seconds(15), 1338);
+ {
+ e->OnLabelsBegin();
+ e->OnLabel("metric", "multiple");
+ e->OnLabel("labels", "l6");
+ e->OnLabelsEnd();
+ }
+ e->OnMetricEnd();
+ }
+ e->OnStreamEnd();
+ e->Close();
+ json += "\n";
+
auto parseJson = [] (auto buf) {
NJson::TJsonValue value;
NJson::ReadJsonTree(buf, &value, true);
return value;
};
- const auto expectedJson = NResource::Find(expectedResourceKey);
+ const auto expectedJson = NResource::Find(expectedResourceKey);
UNIT_ASSERT_EQUAL(parseJson(json), parseJson(expectedJson));
- };
-
- check(false, false, "/expected.json");
- check(false, true, "/expected_buffered.json");
- check(true, false, "/expected_cloud.json");
- check(true, true, "/expected_cloud_buffered.json");
- }
-
- TLogHistogramSnapshotPtr TestLogHistogram(ui32 v = 1) {
- TVector<double> buckets{0.5 * v, 0.25 * v, 0.25 * v, 0.5 * v};
- return MakeIntrusive<TLogHistogramSnapshot>(1.5, 1u, 0, std::move(buckets));
- }
-
- Y_UNIT_TEST(HistogramAndSummaryMetricTypesAreNotSupportedByCloudJson) {
- const TInstant now = TInstant::ParseIso8601Deprecated("2017-11-05T01:02:03Z");
-
- auto emit = [&](IMetricEncoder* encoder, EMetricType metricType) {
- encoder->OnStreamBegin();
+ };
+
+ check(false, false, "/expected.json");
+ check(false, true, "/expected_buffered.json");
+ check(true, false, "/expected_cloud.json");
+ check(true, true, "/expected_cloud_buffered.json");
+ }
+
+ TLogHistogramSnapshotPtr TestLogHistogram(ui32 v = 1) {
+ TVector<double> buckets{0.5 * v, 0.25 * v, 0.25 * v, 0.5 * v};
+ return MakeIntrusive<TLogHistogramSnapshot>(1.5, 1u, 0, std::move(buckets));
+ }
+
+ Y_UNIT_TEST(HistogramAndSummaryMetricTypesAreNotSupportedByCloudJson) {
+ const TInstant now = TInstant::ParseIso8601Deprecated("2017-11-05T01:02:03Z");
+
+ auto emit = [&](IMetricEncoder* encoder, EMetricType metricType) {
+ encoder->OnStreamBegin();
{
- encoder->OnMetricBegin(metricType);
- {
- encoder->OnLabelsBegin();
- encoder->OnLabel("name", "m");
- encoder->OnLabelsEnd();
- }
-
- switch (metricType) {
- case EMetricType::HIST: {
- auto histogram = ExponentialHistogram(6, 2);
- encoder->OnHistogram(now, histogram->Snapshot());
- break;
- }
- case EMetricType::LOGHIST: {
- auto histogram = TestLogHistogram();
- encoder->OnLogHistogram(now, histogram);
- break;
- }
- case EMetricType::DSUMMARY: {
- auto summary = MakeIntrusive<TSummaryDoubleSnapshot>(10., -0.5, 0.5, 0.3, 30u);
- encoder->OnSummaryDouble(now, summary);
- break;
- }
- default:
- Y_FAIL("unexpected metric type [%s]", ToString(metricType).c_str());
- }
-
- encoder->OnMetricEnd();
+ encoder->OnMetricBegin(metricType);
+ {
+ encoder->OnLabelsBegin();
+ encoder->OnLabel("name", "m");
+ encoder->OnLabelsEnd();
+ }
+
+ switch (metricType) {
+ case EMetricType::HIST: {
+ auto histogram = ExponentialHistogram(6, 2);
+ encoder->OnHistogram(now, histogram->Snapshot());
+ break;
+ }
+ case EMetricType::LOGHIST: {
+ auto histogram = TestLogHistogram();
+ encoder->OnLogHistogram(now, histogram);
+ break;
+ }
+ case EMetricType::DSUMMARY: {
+ auto summary = MakeIntrusive<TSummaryDoubleSnapshot>(10., -0.5, 0.5, 0.3, 30u);
+ encoder->OnSummaryDouble(now, summary);
+ break;
+ }
+ default:
+ Y_FAIL("unexpected metric type [%s]", ToString(metricType).c_str());
+ }
+
+ encoder->OnMetricEnd();
}
- encoder->OnStreamEnd();
- encoder->Close();
- };
-
- auto doTest = [&](bool buffered, EMetricType metricType) {
- TString json;
- TStringOutput out(json);
- auto encoder = buffered ? BufferedEncoderCloudJson(&out, 2) : EncoderCloudJson(&out, 2);
- const TString expectedMessage = TStringBuilder()
- << "metric type '" << metricType << "' is not supported by cloud json format";
- UNIT_ASSERT_EXCEPTION_CONTAINS_C(emit(encoder.Get(), metricType), yexception, expectedMessage,
- TString("buffered: ") + ToString(buffered));
- };
-
- doTest(false, EMetricType::HIST);
- doTest(false, EMetricType::LOGHIST);
- doTest(false, EMetricType::DSUMMARY);
- doTest(true, EMetricType::HIST);
- doTest(true, EMetricType::LOGHIST);
- doTest(true, EMetricType::DSUMMARY);
+ encoder->OnStreamEnd();
+ encoder->Close();
+ };
+
+ auto doTest = [&](bool buffered, EMetricType metricType) {
+ TString json;
+ TStringOutput out(json);
+ auto encoder = buffered ? BufferedEncoderCloudJson(&out, 2) : EncoderCloudJson(&out, 2);
+ const TString expectedMessage = TStringBuilder()
+ << "metric type '" << metricType << "' is not supported by cloud json format";
+ UNIT_ASSERT_EXCEPTION_CONTAINS_C(emit(encoder.Get(), metricType), yexception, expectedMessage,
+ TString("buffered: ") + ToString(buffered));
+ };
+
+ doTest(false, EMetricType::HIST);
+ doTest(false, EMetricType::LOGHIST);
+ doTest(false, EMetricType::DSUMMARY);
+ doTest(true, EMetricType::HIST);
+ doTest(true, EMetricType::LOGHIST);
+ doTest(true, EMetricType::DSUMMARY);
}
Y_UNIT_TEST(MetricsWithDifferentLabelOrderGetMerged) {
@@ -369,13 +369,13 @@ Y_UNIT_TEST_SUITE(TJsonTest) {
UNIT_ASSERT_VALUES_EQUAL(samples.CommonLabelsSize(), 1);
AssertLabelEqual(samples.GetCommonLabels(0), "project", "solomon");
- UNIT_ASSERT_VALUES_EQUAL(samples.SamplesSize(), 6);
+ UNIT_ASSERT_VALUES_EQUAL(samples.SamplesSize(), 6);
{
const NProto::TMultiSample& s = samples.GetSamples(0);
UNIT_ASSERT_EQUAL(s.GetMetricType(), NProto::COUNTER);
UNIT_ASSERT_VALUES_EQUAL(s.LabelsSize(), 2);
AssertLabelEqual(s.GetLabels(0), "metric", "single");
- AssertLabelEqual(s.GetLabels(1), "labels", "l1");
+ AssertLabelEqual(s.GetLabels(1), "labels", "l1");
UNIT_ASSERT_VALUES_EQUAL(s.PointsSize(), 1);
AssertPointEqual(s.GetPoints(0), now, ui64(17));
@@ -385,7 +385,7 @@ Y_UNIT_TEST_SUITE(TJsonTest) {
UNIT_ASSERT_EQUAL(s.GetMetricType(), NProto::RATE);
UNIT_ASSERT_VALUES_EQUAL(s.LabelsSize(), 2);
AssertLabelEqual(s.GetLabels(0), "metric", "single");
- AssertLabelEqual(s.GetLabels(1), "labels", "l2");
+ AssertLabelEqual(s.GetLabels(1), "labels", "l2");
UNIT_ASSERT_VALUES_EQUAL(s.PointsSize(), 1);
AssertPointEqual(s.GetPoints(0), now, ui64(17));
@@ -395,27 +395,27 @@ Y_UNIT_TEST_SUITE(TJsonTest) {
UNIT_ASSERT_EQUAL(s.GetMetricType(), NProto::GAUGE);
UNIT_ASSERT_VALUES_EQUAL(s.LabelsSize(), 2);
AssertLabelEqual(s.GetLabels(0), "metric", "single");
- AssertLabelEqual(s.GetLabels(1), "labels", "l3");
+ AssertLabelEqual(s.GetLabels(1), "labels", "l3");
UNIT_ASSERT_VALUES_EQUAL(s.PointsSize(), 1);
AssertPointEqual(s.GetPoints(0), now, 3.14);
}
{
const NProto::TMultiSample& s = samples.GetSamples(3);
- UNIT_ASSERT_EQUAL(s.GetMetricType(), NProto::IGAUGE);
- UNIT_ASSERT_VALUES_EQUAL(s.LabelsSize(), 2);
- AssertLabelEqual(s.GetLabels(0), "metric", "single_igauge");
- AssertLabelEqual(s.GetLabels(1), "labels", "l4");
-
- UNIT_ASSERT_VALUES_EQUAL(s.PointsSize(), 1);
- AssertPointEqual(s.GetPoints(0), now, i64(42));
- }
- {
- const NProto::TMultiSample& s = samples.GetSamples(4);
+ UNIT_ASSERT_EQUAL(s.GetMetricType(), NProto::IGAUGE);
+ UNIT_ASSERT_VALUES_EQUAL(s.LabelsSize(), 2);
+ AssertLabelEqual(s.GetLabels(0), "metric", "single_igauge");
+ AssertLabelEqual(s.GetLabels(1), "labels", "l4");
+
+ UNIT_ASSERT_VALUES_EQUAL(s.PointsSize(), 1);
+ AssertPointEqual(s.GetPoints(0), now, i64(42));
+ }
+ {
+ const NProto::TMultiSample& s = samples.GetSamples(4);
UNIT_ASSERT_EQUAL(s.GetMetricType(), NProto::GAUGE);
UNIT_ASSERT_VALUES_EQUAL(s.LabelsSize(), 2);
AssertLabelEqual(s.GetLabels(0), "metric", "multiple");
- AssertLabelEqual(s.GetLabels(1), "labels", "l5");
+ AssertLabelEqual(s.GetLabels(1), "labels", "l5");
UNIT_ASSERT_VALUES_EQUAL(s.PointsSize(), 3);
AssertPointEqualNan(s.GetPoints(0), now);
@@ -423,11 +423,11 @@ Y_UNIT_TEST_SUITE(TJsonTest) {
AssertPointEqualInf(s.GetPoints(2), now + TDuration::Seconds(30), -11);
}
{
- const NProto::TMultiSample& s = samples.GetSamples(5);
+ const NProto::TMultiSample& s = samples.GetSamples(5);
UNIT_ASSERT_EQUAL(s.GetMetricType(), NProto::COUNTER);
UNIT_ASSERT_VALUES_EQUAL(s.LabelsSize(), 2);
AssertLabelEqual(s.GetLabels(0), "metric", "multiple");
- AssertLabelEqual(s.GetLabels(1), "labels", "l6");
+ AssertLabelEqual(s.GetLabels(1), "labels", "l6");
UNIT_ASSERT_VALUES_EQUAL(s.PointsSize(), 2);
AssertPointEqual(s.GetPoints(0), now, ui64(1337));
@@ -1158,61 +1158,61 @@ Y_UNIT_TEST_SUITE(TJsonTest) {
UNIT_ASSERT_NO_DIFF(result2, NResource::Find("/int_gauge.json"));
}
- Y_UNIT_TEST(InconsistentMetricTypes) {
- auto emitMetrics = [](IMetricEncoder& encoder, const TString& expectedError) {
- encoder.OnMetricBegin(EMetricType::GAUGE);
- {
- encoder.OnLabelsBegin();
- encoder.OnLabel("name", "m");
- encoder.OnLabel("l1", "v1");
- encoder.OnLabel("l2", "v2");
- encoder.OnLabelsEnd();
- }
- encoder.OnDouble(now, 1.0);
- encoder.OnMetricEnd();
-
- encoder.OnMetricBegin(EMetricType::COUNTER);
- {
- encoder.OnLabelsBegin();
- encoder.OnLabel("name", "m");
- encoder.OnLabel("l1", "v1");
- encoder.OnLabel("l2", "v2");
- encoder.OnLabelsEnd();
- }
- encoder.OnUint64(now, 1);
-
- UNIT_ASSERT_EXCEPTION_CONTAINS(encoder.OnMetricEnd(),
- yexception,
- expectedError);
- };
-
- {
- TStringStream out;
- auto encoder = BufferedEncoderJson(&out);
-
- encoder->OnStreamBegin();
- encoder->OnLabelsBegin();
- encoder->OnLabel("c", "cv");
- encoder->OnLabelsEnd();
- emitMetrics(*encoder,
- "Time series point type mismatch: expected DOUBLE but found UINT64, "
- "labels '{c=cv, l1=v1, l2=v2, name=m}'");
- }
-
- {
- TStringStream out;
- auto encoder = BufferedEncoderJson(&out);
-
- encoder->OnStreamBegin();
- encoder->OnLabelsBegin();
- encoder->OnLabel("l1", "v100");
- encoder->OnLabelsEnd();
- emitMetrics(*encoder,
- "Time series point type mismatch: expected DOUBLE but found UINT64, "
- "labels '{l1=v1, l2=v2, name=m}'");
- }
- }
-
+ Y_UNIT_TEST(InconsistentMetricTypes) {
+ auto emitMetrics = [](IMetricEncoder& encoder, const TString& expectedError) {
+ encoder.OnMetricBegin(EMetricType::GAUGE);
+ {
+ encoder.OnLabelsBegin();
+ encoder.OnLabel("name", "m");
+ encoder.OnLabel("l1", "v1");
+ encoder.OnLabel("l2", "v2");
+ encoder.OnLabelsEnd();
+ }
+ encoder.OnDouble(now, 1.0);
+ encoder.OnMetricEnd();
+
+ encoder.OnMetricBegin(EMetricType::COUNTER);
+ {
+ encoder.OnLabelsBegin();
+ encoder.OnLabel("name", "m");
+ encoder.OnLabel("l1", "v1");
+ encoder.OnLabel("l2", "v2");
+ encoder.OnLabelsEnd();
+ }
+ encoder.OnUint64(now, 1);
+
+ UNIT_ASSERT_EXCEPTION_CONTAINS(encoder.OnMetricEnd(),
+ yexception,
+ expectedError);
+ };
+
+ {
+ TStringStream out;
+ auto encoder = BufferedEncoderJson(&out);
+
+ encoder->OnStreamBegin();
+ encoder->OnLabelsBegin();
+ encoder->OnLabel("c", "cv");
+ encoder->OnLabelsEnd();
+ emitMetrics(*encoder,
+ "Time series point type mismatch: expected DOUBLE but found UINT64, "
+ "labels '{c=cv, l1=v1, l2=v2, name=m}'");
+ }
+
+ {
+ TStringStream out;
+ auto encoder = BufferedEncoderJson(&out);
+
+ encoder->OnStreamBegin();
+ encoder->OnLabelsBegin();
+ encoder->OnLabel("l1", "v100");
+ encoder->OnLabelsEnd();
+ emitMetrics(*encoder,
+ "Time series point type mismatch: expected DOUBLE but found UINT64, "
+ "labels '{l1=v1, l2=v2, name=m}'");
+ }
+ }
+
Y_UNIT_TEST(IntGaugeDecode) {
NProto::TMultiSamplesList samples;
{
diff --git a/library/cpp/monlib/encode/json/ut/expected.json b/library/cpp/monlib/encode/json/ut/expected.json
index ead853455b..30c405b0bd 100644
--- a/library/cpp/monlib/encode/json/ut/expected.json
+++ b/library/cpp/monlib/encode/json/ut/expected.json
@@ -11,7 +11,7 @@
"labels":
{
"metric":"single",
- "labels":"l1"
+ "labels":"l1"
},
"ts":1509843723,
"value":17
@@ -21,7 +21,7 @@
"labels":
{
"metric":"single",
- "labels":"l2"
+ "labels":"l2"
},
"ts":1509843723,
"value":17
@@ -31,27 +31,27 @@
"labels":
{
"metric":"single",
- "labels":"l3"
+ "labels":"l3"
},
"ts":1509843723,
"value":3.14
},
{
- "kind":"IGAUGE",
- "labels":
- {
- "metric":"single_igauge",
- "labels":"l4"
- },
- "ts":1509843723,
- "value":42
- },
- {
+ "kind":"IGAUGE",
+ "labels":
+ {
+ "metric":"single_igauge",
+ "labels":"l4"
+ },
+ "ts":1509843723,
+ "value":42
+ },
+ {
"kind":"GAUGE",
"labels":
{
"metric":"multiple",
- "labels":"l5"
+ "labels":"l5"
},
"timeseries":
[
@@ -85,7 +85,7 @@
"labels":
{
"metric":"multiple",
- "labels":"l6"
+ "labels":"l6"
}
}
]
diff --git a/library/cpp/monlib/encode/json/ut/expected_buffered.json b/library/cpp/monlib/encode/json/ut/expected_buffered.json
index 9a6a1d6201..0a33842437 100644
--- a/library/cpp/monlib/encode/json/ut/expected_buffered.json
+++ b/library/cpp/monlib/encode/json/ut/expected_buffered.json
@@ -37,16 +37,16 @@
"value":3.14
},
{
- "kind":"IGAUGE",
- "labels":
- {
+ "kind":"IGAUGE",
+ "labels":
+ {
"labels":"l4",
"metric":"single_igauge"
- },
- "ts":1509843723,
- "value":42
- },
- {
+ },
+ "ts":1509843723,
+ "value":42
+ },
+ {
"kind":"GAUGE",
"labels":
{
@@ -71,11 +71,11 @@
},
{
"kind":"COUNTER",
- "labels":
- {
+ "labels":
+ {
"labels":"l6",
"metric":"multiple"
- },
+ },
"timeseries":
[
{
@@ -86,7 +86,7 @@
"ts":1509843738,
"value":1338
}
- ]
+ ]
}
]
}
diff --git a/library/cpp/monlib/encode/json/ut/expected_cloud.json b/library/cpp/monlib/encode/json/ut/expected_cloud.json
index 6184811579..78e90ec3be 100644
--- a/library/cpp/monlib/encode/json/ut/expected_cloud.json
+++ b/library/cpp/monlib/encode/json/ut/expected_cloud.json
@@ -1,92 +1,92 @@
{
- "ts":"2017-07-14T02:40:00.000000Z",
- "labels":
+ "ts":"2017-07-14T02:40:00.000000Z",
+ "labels":
{
"project":"solomon"
},
- "metrics":
+ "metrics":
[
{
- "type":"COUNTER",
+ "type":"COUNTER",
"labels":
{
- "labels":"l1"
+ "labels":"l1"
},
- "name":"single",
- "ts":"2017-11-05T01:02:03.000000Z",
+ "name":"single",
+ "ts":"2017-11-05T01:02:03.000000Z",
"value":17
},
{
- "type":"RATE",
+ "type":"RATE",
"labels":
{
- "labels":"l2"
+ "labels":"l2"
},
- "name":"single",
- "ts":"2017-11-05T01:02:03.000000Z",
+ "name":"single",
+ "ts":"2017-11-05T01:02:03.000000Z",
"value":17
},
{
- "type":"DGAUGE",
+ "type":"DGAUGE",
"labels":
{
- "labels":"l3"
+ "labels":"l3"
},
- "name":"single",
- "ts":"2017-11-05T01:02:03.000000Z",
+ "name":"single",
+ "ts":"2017-11-05T01:02:03.000000Z",
"value":3.14
},
{
- "type":"IGAUGE",
+ "type":"IGAUGE",
"labels":
{
- "labels":"l4"
+ "labels":"l4"
},
- "name":"single_igauge",
- "ts":"2017-11-05T01:02:03.000000Z",
- "value":42
- },
- {
- "type":"DGAUGE",
- "labels":
- {
- "labels":"l5"
- },
- "name":"multiple",
+ "name":"single_igauge",
+ "ts":"2017-11-05T01:02:03.000000Z",
+ "value":42
+ },
+ {
+ "type":"DGAUGE",
+ "labels":
+ {
+ "labels":"l5"
+ },
+ "name":"multiple",
"timeseries":
[
{
- "ts":"2017-11-05T01:02:03.000000Z",
+ "ts":"2017-11-05T01:02:03.000000Z",
"value":"nan"
},
{
- "ts":"2017-11-05T01:02:18.000000Z",
+ "ts":"2017-11-05T01:02:18.000000Z",
"value":"inf"
},
{
- "ts":"2017-11-05T01:02:33.000000Z",
+ "ts":"2017-11-05T01:02:33.000000Z",
"value":"-inf"
}
]
},
{
- "type":"COUNTER",
+ "type":"COUNTER",
"timeseries":
[
{
- "ts":"2017-11-05T01:02:03.000000Z",
+ "ts":"2017-11-05T01:02:03.000000Z",
"value":1337
},
{
- "ts":"2017-11-05T01:02:18.000000Z",
+ "ts":"2017-11-05T01:02:18.000000Z",
"value":1338
}
],
"labels":
{
- "labels":"l6"
- },
- "name":"multiple"
+ "labels":"l6"
+ },
+ "name":"multiple"
}
]
}
diff --git a/library/cpp/monlib/encode/json/ut/expected_cloud_buffered.json b/library/cpp/monlib/encode/json/ut/expected_cloud_buffered.json
index be237d522b..5b7aeb836e 100644
--- a/library/cpp/monlib/encode/json/ut/expected_cloud_buffered.json
+++ b/library/cpp/monlib/encode/json/ut/expected_cloud_buffered.json
@@ -1,92 +1,92 @@
-{
- "ts":"2017-07-14T02:40:00.000000Z",
- "labels":
- {
- "project":"solomon"
- },
- "metrics":
- [
- {
- "type":"COUNTER",
- "labels":
- {
- "labels":"l1"
- },
- "name":"single",
- "ts":"2017-11-05T01:02:03.000000Z",
- "value":17
- },
- {
- "type":"RATE",
- "labels":
- {
- "labels":"l2"
- },
- "name":"single",
- "ts":"2017-11-05T01:02:03.000000Z",
- "value":17
- },
- {
- "type":"DGAUGE",
- "labels":
- {
- "labels":"l3"
- },
- "name":"single",
- "ts":"2017-11-05T01:02:03.000000Z",
- "value":3.14
- },
- {
- "type":"IGAUGE",
- "labels":
- {
- "labels":"l4"
- },
- "name":"single_igauge",
- "ts":"2017-11-05T01:02:03.000000Z",
- "value":42
- },
- {
- "type":"DGAUGE",
- "labels":
- {
- "labels":"l5"
- },
- "name":"multiple",
- "timeseries":
- [
- {
- "ts":"2017-11-05T01:02:03.000000Z",
- "value":"nan"
- },
- {
- "ts":"2017-11-05T01:02:18.000000Z",
- "value":"inf"
- },
- {
- "ts":"2017-11-05T01:02:33.000000Z",
- "value":"-inf"
- }
- ]
- },
- {
- "type":"COUNTER",
- "labels":
- {
- "labels":"l6"
- },
- "name":"multiple",
- "timeseries":
- [
- {
- "ts":"2017-11-05T01:02:03.000000Z",
- "value":1337
- },
- {
- "ts":"2017-11-05T01:02:18.000000Z",
- "value":1338
- }
- ]
- }
- ]
-}
+{
+ "ts":"2017-07-14T02:40:00.000000Z",
+ "labels":
+ {
+ "project":"solomon"
+ },
+ "metrics":
+ [
+ {
+ "type":"COUNTER",
+ "labels":
+ {
+ "labels":"l1"
+ },
+ "name":"single",
+ "ts":"2017-11-05T01:02:03.000000Z",
+ "value":17
+ },
+ {
+ "type":"RATE",
+ "labels":
+ {
+ "labels":"l2"
+ },
+ "name":"single",
+ "ts":"2017-11-05T01:02:03.000000Z",
+ "value":17
+ },
+ {
+ "type":"DGAUGE",
+ "labels":
+ {
+ "labels":"l3"
+ },
+ "name":"single",
+ "ts":"2017-11-05T01:02:03.000000Z",
+ "value":3.14
+ },
+ {
+ "type":"IGAUGE",
+ "labels":
+ {
+ "labels":"l4"
+ },
+ "name":"single_igauge",
+ "ts":"2017-11-05T01:02:03.000000Z",
+ "value":42
+ },
+ {
+ "type":"DGAUGE",
+ "labels":
+ {
+ "labels":"l5"
+ },
+ "name":"multiple",
+ "timeseries":
+ [
+ {
+ "ts":"2017-11-05T01:02:03.000000Z",
+ "value":"nan"
+ },
+ {
+ "ts":"2017-11-05T01:02:18.000000Z",
+ "value":"inf"
+ },
+ {
+ "ts":"2017-11-05T01:02:33.000000Z",
+ "value":"-inf"
+ }
+ ]
+ },
+ {
+ "type":"COUNTER",
+ "labels":
+ {
+ "labels":"l6"
+ },
+ "name":"multiple",
+ "timeseries":
+ [
+ {
+ "ts":"2017-11-05T01:02:03.000000Z",
+ "value":1337
+ },
+ {
+ "ts":"2017-11-05T01:02:18.000000Z",
+ "value":1338
+ }
+ ]
+ }
+ ]
+}
diff --git a/library/cpp/monlib/encode/json/ut/ya.make b/library/cpp/monlib/encode/json/ut/ya.make
index e50c4f4903..851443ae62 100644
--- a/library/cpp/monlib/encode/json/ut/ya.make
+++ b/library/cpp/monlib/encode/json/ut/ya.make
@@ -15,9 +15,9 @@ RESOURCE(
buffered_ts_merge.json /buffered_ts_merge.json
empty_series.json /empty_series.json
expected.json /expected.json
- expected_buffered.json /expected_buffered.json
- expected_cloud.json /expected_cloud.json
- expected_cloud_buffered.json /expected_cloud_buffered.json
+ expected_buffered.json /expected_buffered.json
+ expected_cloud.json /expected_cloud.json
+ expected_cloud_buffered.json /expected_cloud_buffered.json
merged.json /merged.json
histogram_timeseries.json /histogram_timeseries.json
histogram_value.json /histogram_value.json