diff options
author | iddqd <iddqd@yandex-team.ru> | 2022-02-10 16:49:45 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:45 +0300 |
commit | 07fce9c5f7771600d0b3d70e1f88fd8a7e164d85 (patch) | |
tree | e4aa4750fbb864d70f8c06cf03d2750e979ea3bf /library/cpp/monlib | |
parent | af42068bf6cd93c976b80dd0388fa48cdf65da11 (diff) | |
download | ydb-07fce9c5f7771600d0b3d70e1f88fd8a7e164d85.tar.gz |
Restoring authorship annotation for <iddqd@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib')
5 files changed, 54 insertions, 54 deletions
diff --git a/library/cpp/monlib/encode/prometheus/prometheus_encoder_ut.cpp b/library/cpp/monlib/encode/prometheus/prometheus_encoder_ut.cpp index fd9debb060..4a0b9c36f9 100644 --- a/library/cpp/monlib/encode/prometheus/prometheus_encoder_ut.cpp +++ b/library/cpp/monlib/encode/prometheus/prometheus_encoder_ut.cpp @@ -367,48 +367,48 @@ Y_UNIT_TEST_SUITE(TPrometheusEncoderTest) { "bytesRx_count{host=\"solomon-sas-01\", dc=\"sas\", } 17 1512216010000\n" "\n"); } - - Y_UNIT_TEST(CommonLables) { - auto result = EncodeToString([](IMetricEncoder* e) { - e->OnStreamBegin(); - { // common time - e->OnCommonTime(TInstant::Seconds(1500000000)); - } - { // common labels - e->OnLabelsBegin(); - e->OnLabel("project", "solomon"); - e->OnLabelsEnd(); - } - { // metric #1 - e->OnMetricBegin(EMetricType::COUNTER); - { - e->OnLabelsBegin(); - e->OnLabel("sensor", "single"); - e->OnLabel("labels", "l1"); - e->OnLabelsEnd(); - } - e->OnUint64(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:10Z"), 17); - e->OnMetricEnd(); - } - { // metric #2 - e->OnMetricBegin(EMetricType::COUNTER); - { - e->OnLabelsBegin(); - e->OnLabel("sensor", "two"); - e->OnLabel("labels", "l2"); - e->OnLabelsEnd(); - } - e->OnUint64(TInstant::Zero(), 42); - e->OnMetricEnd(); - } - e->OnStreamEnd(); - }); - UNIT_ASSERT_STRINGS_EQUAL(result, -R"(# TYPE single counter -single{labels="l1", project="solomon", } 17 1512216010000 -# TYPE two counter -two{labels="l2", project="solomon", } 42 1500000000000 - -)"); - } + + Y_UNIT_TEST(CommonLables) { + auto result = EncodeToString([](IMetricEncoder* e) { + e->OnStreamBegin(); + { // common time + e->OnCommonTime(TInstant::Seconds(1500000000)); + } + { // common labels + e->OnLabelsBegin(); + e->OnLabel("project", "solomon"); + e->OnLabelsEnd(); + } + { // metric #1 + e->OnMetricBegin(EMetricType::COUNTER); + { + e->OnLabelsBegin(); + e->OnLabel("sensor", "single"); + e->OnLabel("labels", "l1"); + e->OnLabelsEnd(); + } + e->OnUint64(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:10Z"), 17); + e->OnMetricEnd(); + } + { // metric #2 + e->OnMetricBegin(EMetricType::COUNTER); + { + e->OnLabelsBegin(); + e->OnLabel("sensor", "two"); + e->OnLabel("labels", "l2"); + e->OnLabelsEnd(); + } + e->OnUint64(TInstant::Zero(), 42); + e->OnMetricEnd(); + } + e->OnStreamEnd(); + }); + UNIT_ASSERT_STRINGS_EQUAL(result, +R"(# TYPE single counter +single{labels="l1", project="solomon", } 17 1512216010000 +# TYPE two counter +two{labels="l2", project="solomon", } 42 1500000000000 + +)"); + } } diff --git a/library/cpp/monlib/service/pages/registry_mon_page.cpp b/library/cpp/monlib/service/pages/registry_mon_page.cpp index c59e50f622..35c499e0dc 100644 --- a/library/cpp/monlib/service/pages/registry_mon_page.cpp +++ b/library/cpp/monlib/service/pages/registry_mon_page.cpp @@ -2,7 +2,7 @@ #include <library/cpp/monlib/encode/text/text.h> #include <library/cpp/monlib/encode/json/json.h> -#include <library/cpp/monlib/encode/prometheus/prometheus.h> +#include <library/cpp/monlib/encode/prometheus/prometheus.h> #include <library/cpp/monlib/encode/spack/spack_v1.h> #include <library/cpp/monlib/service/format.h> @@ -22,9 +22,9 @@ namespace NMonitoring { resp = HTTPOKSPACK; const auto compression = ParseCompression(request); encoder = NMonitoring::EncoderSpackV1(&out, ETimePrecision::SECONDS, compression); - } else if (formatStr == TStringBuf("prometheus")) { - resp = HTTPOKPROMETHEUS; - encoder = NMonitoring::EncoderPrometheus(&out); + } else if (formatStr == TStringBuf("prometheus")) { + resp = HTTPOKPROMETHEUS; + encoder = NMonitoring::EncoderPrometheus(&out); } else { ythrow yexception() << "unsupported metric encoding format: " << formatStr; } diff --git a/library/cpp/monlib/service/pages/registry_mon_page.h b/library/cpp/monlib/service/pages/registry_mon_page.h index 2d26d3319c..f76017c3a7 100644 --- a/library/cpp/monlib/service/pages/registry_mon_page.h +++ b/library/cpp/monlib/service/pages/registry_mon_page.h @@ -5,7 +5,7 @@ #include <library/cpp/monlib/metrics/metric_registry.h> namespace NMonitoring { - // For now this class can only enumerate all metrics without any grouping or serve JSON/Spack/Prometheus + // For now this class can only enumerate all metrics without any grouping or serve JSON/Spack/Prometheus class TMetricRegistryPage: public TPreMonPage { public: TMetricRegistryPage(const TString& path, const TString& title, TAtomicSharedPtr<IMetricSupplier> registry) diff --git a/library/cpp/monlib/service/pages/ya.make b/library/cpp/monlib/service/pages/ya.make index 48d44a0838..6af26f73f4 100644 --- a/library/cpp/monlib/service/pages/ya.make +++ b/library/cpp/monlib/service/pages/ya.make @@ -25,7 +25,7 @@ PEERDIR( library/cpp/monlib/encode/json library/cpp/monlib/encode/text library/cpp/monlib/encode/spack - library/cpp/monlib/encode/prometheus + library/cpp/monlib/encode/prometheus ) END() diff --git a/library/cpp/monlib/service/service.cpp b/library/cpp/monlib/service/service.cpp index 929efbf816..8571549b14 100644 --- a/library/cpp/monlib/service/service.cpp +++ b/library/cpp/monlib/service/service.cpp @@ -47,10 +47,10 @@ namespace NMonitoring { Handler(out, *this); out.Finish(); } catch (...) { - auto msg = CurrentExceptionMessage(); - out << "HTTP/1.1 500 Internal server error\r\nConnection: Close\r\n\r\n" << msg; - out.Finish(); - YSYSLOG(TLOG_ERR, "THttpClient: error while serving monitoring request: %s", msg.data()); + auto msg = CurrentExceptionMessage(); + out << "HTTP/1.1 500 Internal server error\r\nConnection: Close\r\n\r\n" << msg; + out.Finish(); + YSYSLOG(TLOG_ERR, "THttpClient: error while serving monitoring request: %s", msg.data()); } } |