aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/deprecated
diff options
context:
space:
mode:
authornga <nga@yandex-team.ru>2022-02-10 16:48:09 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:09 +0300
commit1f553f46fb4f3c5eec631352cdd900a0709016af (patch)
treea231fba2c03b440becaea6c86a2702d0bfb0336e /library/cpp/monlib/deprecated
parentc4de7efdedc25b49cbea74bd589eecb61b55b60a (diff)
downloadydb-1f553f46fb4f3c5eec631352cdd900a0709016af.tar.gz
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/deprecated')
-rw-r--r--library/cpp/monlib/deprecated/json/ut/ya.make12
-rw-r--r--library/cpp/monlib/deprecated/json/writer.cpp34
-rw-r--r--library/cpp/monlib/deprecated/json/writer.h92
-rw-r--r--library/cpp/monlib/deprecated/json/writer_ut.cpp38
-rw-r--r--library/cpp/monlib/deprecated/json/ya.make18
5 files changed, 97 insertions, 97 deletions
diff --git a/library/cpp/monlib/deprecated/json/ut/ya.make b/library/cpp/monlib/deprecated/json/ut/ya.make
index 18315993b5..556b0c8291 100644
--- a/library/cpp/monlib/deprecated/json/ut/ya.make
+++ b/library/cpp/monlib/deprecated/json/ut/ya.make
@@ -1,12 +1,12 @@
UNITTEST_FOR(library/cpp/monlib/deprecated/json)
-
+
OWNER(
jamel
g:solomon
)
-
-SRCS(
+
+SRCS(
writer_ut.cpp
-)
-
-END()
+)
+
+END()
diff --git a/library/cpp/monlib/deprecated/json/writer.cpp b/library/cpp/monlib/deprecated/json/writer.cpp
index a581f2e07a..9917288687 100644
--- a/library/cpp/monlib/deprecated/json/writer.cpp
+++ b/library/cpp/monlib/deprecated/json/writer.cpp
@@ -1,36 +1,36 @@
#include "writer.h"
-
+
namespace NMonitoring {
TDeprecatedJsonWriter::TDeprecatedJsonWriter(IOutputStream* out)
: JsonWriter(out, false)
, State(STATE_ROOT)
{
}
-
+
void TDeprecatedJsonWriter::TransitionState(EState current, EState next) {
if (State != current) {
ythrow yexception() << "wrong state";
}
State = next;
}
-
+
void TDeprecatedJsonWriter::OpenDocument() {
TransitionState(STATE_ROOT, STATE_DOCUMENT);
JsonWriter.OpenMap();
- }
-
+ }
+
void TDeprecatedJsonWriter::CloseDocument() {
TransitionState(STATE_DOCUMENT, STATE_ROOT);
JsonWriter.CloseMap();
JsonWriter.Flush();
}
-
+
void TDeprecatedJsonWriter::OpenCommonLabels() {
TransitionState(STATE_DOCUMENT, STATE_COMMON_LABELS);
JsonWriter.Write("commonLabels");
JsonWriter.OpenMap();
}
-
+
void TDeprecatedJsonWriter::CloseCommonLabels() {
TransitionState(STATE_COMMON_LABELS, STATE_DOCUMENT);
JsonWriter.CloseMap();
@@ -51,50 +51,50 @@ namespace NMonitoring {
TransitionState(STATE_METRICS, STATE_DOCUMENT);
JsonWriter.CloseArray();
}
-
+
void TDeprecatedJsonWriter::OpenMetric() {
TransitionState(STATE_METRICS, STATE_METRIC);
JsonWriter.OpenMap();
}
-
+
void TDeprecatedJsonWriter::CloseMetric() {
TransitionState(STATE_METRIC, STATE_METRICS);
JsonWriter.CloseMap();
}
-
+
void TDeprecatedJsonWriter::OpenLabels() {
TransitionState(STATE_METRIC, STATE_LABELS);
JsonWriter.Write("labels");
JsonWriter.OpenMap();
}
-
+
void TDeprecatedJsonWriter::CloseLabels() {
TransitionState(STATE_LABELS, STATE_METRIC);
JsonWriter.CloseMap();
}
-
+
void TDeprecatedJsonWriter::WriteLabel(TStringBuf name, TStringBuf value) {
TransitionState(STATE_LABELS, STATE_LABELS);
JsonWriter.Write(name, value);
}
-
+
void TDeprecatedJsonWriter::WriteModeDeriv() {
TransitionState(STATE_METRIC, STATE_METRIC);
JsonWriter.Write("mode", "deriv");
}
-
+
void TDeprecatedJsonWriter::WriteValue(long long value) {
TransitionState(STATE_METRIC, STATE_METRIC);
JsonWriter.Write("value", value);
}
-
+
void TDeprecatedJsonWriter::WriteDoubleValue(double value) {
TransitionState(STATE_METRIC, STATE_METRIC);
JsonWriter.Write("value", value);
}
-
+
void TDeprecatedJsonWriter::WriteTs(ui64 ts) {
TransitionState(STATE_METRIC, STATE_METRIC);
JsonWriter.Write("ts", ts);
}
-}
+}
diff --git a/library/cpp/monlib/deprecated/json/writer.h b/library/cpp/monlib/deprecated/json/writer.h
index 183288143c..2ea8ce40c1 100644
--- a/library/cpp/monlib/deprecated/json/writer.h
+++ b/library/cpp/monlib/deprecated/json/writer.h
@@ -1,7 +1,7 @@
-#pragma once
-
+#pragma once
+
#include <library/cpp/json/json_writer.h>
-
+
namespace NMonitoring {
/**
* Deprecated writer of Solomon JSON format
@@ -12,24 +12,24 @@ namespace NMonitoring {
* particular format.
*/
class TDeprecatedJsonWriter {
- private:
- NJson::TJsonWriter JsonWriter;
- enum EState {
- STATE_ROOT,
- STATE_DOCUMENT,
+ private:
+ NJson::TJsonWriter JsonWriter;
+ enum EState {
+ STATE_ROOT,
+ STATE_DOCUMENT,
STATE_COMMON_LABELS,
STATE_METRICS,
STATE_METRIC,
- STATE_LABELS,
- };
- EState State;
+ STATE_LABELS,
+ };
+ EState State;
- public:
+ public:
explicit TDeprecatedJsonWriter(IOutputStream* out);
-
- void OpenDocument();
- void CloseDocument();
-
+
+ void OpenDocument();
+ void CloseDocument();
+
void OpenCommonLabels();
void CloseCommonLabels();
@@ -37,40 +37,40 @@ namespace NMonitoring {
void OpenMetrics();
void CloseMetrics();
-
+
void OpenMetric();
void CloseMetric();
-
- void OpenLabels();
- void CloseLabels();
-
- void WriteLabel(TStringBuf name, TStringBuf value);
-
- template <typename... T>
- void WriteLabels(T... pairs) {
- OpenLabels();
- WriteLabelsInner(pairs...);
- CloseLabels();
- }
-
- void WriteModeDeriv();
-
- void WriteValue(long long value);
- void WriteDoubleValue(double d);
+
+ void OpenLabels();
+ void CloseLabels();
+
+ void WriteLabel(TStringBuf name, TStringBuf value);
+
+ template <typename... T>
+ void WriteLabels(T... pairs) {
+ OpenLabels();
+ WriteLabelsInner(pairs...);
+ CloseLabels();
+ }
+
+ void WriteModeDeriv();
+
+ void WriteValue(long long value);
+ void WriteDoubleValue(double d);
void WriteTs(ui64 ts);
- private:
- void WriteLabelsInner(TStringBuf name, TStringBuf value) {
- WriteLabel(name, value);
- }
-
+ private:
+ void WriteLabelsInner(TStringBuf name, TStringBuf value) {
+ WriteLabel(name, value);
+ }
+
template <typename... T>
- void WriteLabelsInner(TStringBuf name, TStringBuf value, T... pairs) {
- WriteLabel(name, value);
- WriteLabelsInner(pairs...);
- }
-
- inline void TransitionState(EState current, EState next);
- };
+ void WriteLabelsInner(TStringBuf name, TStringBuf value, T... pairs) {
+ WriteLabel(name, value);
+ WriteLabelsInner(pairs...);
+ }
+
+ inline void TransitionState(EState current, EState next);
+ };
}
diff --git a/library/cpp/monlib/deprecated/json/writer_ut.cpp b/library/cpp/monlib/deprecated/json/writer_ut.cpp
index 1f9fc8f393..cd5c4e4d78 100644
--- a/library/cpp/monlib/deprecated/json/writer_ut.cpp
+++ b/library/cpp/monlib/deprecated/json/writer_ut.cpp
@@ -1,32 +1,32 @@
#include "writer.h"
#include <library/cpp/testing/unittest/registar.h>
-
+
using namespace NMonitoring;
-
+
Y_UNIT_TEST_SUITE(JsonWriterTests) {
Y_UNIT_TEST(One) {
- TStringStream ss;
+ TStringStream ss;
TDeprecatedJsonWriter w(&ss);
- w.OpenDocument();
+ w.OpenDocument();
w.OpenMetrics();
-
- for (int i = 0; i < 5; ++i) {
+
+ for (int i = 0; i < 5; ++i) {
w.OpenMetric();
- w.OpenLabels();
+ w.OpenLabels();
w.WriteLabel("user", TString("") + (char)('a' + i));
w.WriteLabel("name", "NWrites");
- w.CloseLabels();
- if (i % 2 == 0) {
- w.WriteModeDeriv();
- }
- w.WriteValue(10l);
+ w.CloseLabels();
+ if (i % 2 == 0) {
+ w.WriteModeDeriv();
+ }
+ w.WriteValue(10l);
w.CloseMetric();
- }
-
+ }
+
w.CloseMetrics();
- w.CloseDocument();
-
- //Cout << ss.Str() << "\n";
- }
-}
+ w.CloseDocument();
+
+ //Cout << ss.Str() << "\n";
+ }
+}
diff --git a/library/cpp/monlib/deprecated/json/ya.make b/library/cpp/monlib/deprecated/json/ya.make
index 0ca903ee62..cf49d7367b 100644
--- a/library/cpp/monlib/deprecated/json/ya.make
+++ b/library/cpp/monlib/deprecated/json/ya.make
@@ -1,26 +1,26 @@
-LIBRARY()
-
+LIBRARY()
+
# Deprecated writer of Solomon JSON format
-# https://wiki.yandex-team.ru/solomon/api/dataformat/json
+# https://wiki.yandex-team.ru/solomon/api/dataformat/json
#
# This writer will be deleted soon, so please consider to use
# high level library library/cpp/monlib/encode which is decoupled from the
# particular format.
-
+
OWNER(
jamel
g:solomon
)
-
+
SRCS(
writer.h
writer.cpp
)
-PEERDIR(
+PEERDIR(
library/cpp/json
-)
-
-END()
+)
+
+END()
RECURSE_FOR_TESTS(ut)