diff options
author | tobo <tobo@yandex-team.ru> | 2022-02-10 16:47:27 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:27 +0300 |
commit | 7fe839092527589b38f014d854c51565b3c1adfa (patch) | |
tree | 309e97022d3530044b712b8f71318c78faf7856e /library/cpp/monlib/encode | |
parent | d0d68c395c10da4cb56a1c845504570a04d7893e (diff) | |
download | ydb-7fe839092527589b38f014d854c51565b3c1adfa.tar.gz |
Restoring authorship annotation for <tobo@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/encode')
-rw-r--r-- | library/cpp/monlib/encode/format.cpp | 44 | ||||
-rw-r--r-- | library/cpp/monlib/encode/format.h | 18 | ||||
-rw-r--r-- | library/cpp/monlib/encode/json/json_decoder.cpp | 68 | ||||
-rw-r--r-- | library/cpp/monlib/encode/json/json_decoder_ut.cpp | 14 | ||||
-rw-r--r-- | library/cpp/monlib/encode/json/json_encoder.cpp | 50 | ||||
-rw-r--r-- | library/cpp/monlib/encode/legacy_protobuf/legacy_proto_decoder.cpp | 10 | ||||
-rw-r--r-- | library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp | 10 | ||||
-rw-r--r-- | library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp | 2 | ||||
-rw-r--r-- | library/cpp/monlib/encode/prometheus/prometheus_model.h | 14 | ||||
-rw-r--r-- | library/cpp/monlib/encode/protobuf/protobuf_encoder.cpp | 2 | ||||
-rw-r--r-- | library/cpp/monlib/encode/spack/compression.cpp | 6 | ||||
-rw-r--r-- | library/cpp/monlib/encode/spack/spack_v1_encoder.cpp | 2 | ||||
-rw-r--r-- | library/cpp/monlib/encode/text/text_encoder.cpp | 16 | ||||
-rw-r--r-- | library/cpp/monlib/encode/unistat/unistat_decoder.cpp | 4 | ||||
-rw-r--r-- | library/cpp/monlib/encode/unistat/unistat_ut.cpp | 22 |
15 files changed, 141 insertions, 141 deletions
diff --git a/library/cpp/monlib/encode/format.cpp b/library/cpp/monlib/encode/format.cpp index 400ce5a643..d366b32681 100644 --- a/library/cpp/monlib/encode/format.cpp +++ b/library/cpp/monlib/encode/format.cpp @@ -116,17 +116,17 @@ template <> NMonitoring::EFormat FromStringImpl<NMonitoring::EFormat>(const char* str, size_t len) { using NMonitoring::EFormat; TStringBuf value(str, len); - if (value == TStringBuf("SPACK")) { + if (value == TStringBuf("SPACK")) { return EFormat::SPACK; - } else if (value == TStringBuf("JSON")) { + } else if (value == TStringBuf("JSON")) { return EFormat::JSON; - } else if (value == TStringBuf("PROTOBUF")) { + } else if (value == TStringBuf("PROTOBUF")) { return EFormat::PROTOBUF; - } else if (value == TStringBuf("TEXT")) { + } else if (value == TStringBuf("TEXT")) { return EFormat::TEXT; - } else if (value == TStringBuf("PROMETHEUS")) { + } else if (value == TStringBuf("PROMETHEUS")) { return EFormat::PROMETHEUS; - } else if (value == TStringBuf("UNKNOWN")) { + } else if (value == TStringBuf("UNKNOWN")) { return EFormat::UNKNOWN; } ythrow yexception() << "unknown format: " << value; @@ -137,22 +137,22 @@ void Out<NMonitoring::EFormat>(IOutputStream& o, NMonitoring::EFormat f) { using NMonitoring::EFormat; switch (f) { case EFormat::SPACK: - o << TStringBuf("SPACK"); + o << TStringBuf("SPACK"); return; case EFormat::JSON: - o << TStringBuf("JSON"); + o << TStringBuf("JSON"); return; case EFormat::PROTOBUF: - o << TStringBuf("PROTOBUF"); + o << TStringBuf("PROTOBUF"); return; case EFormat::TEXT: - o << TStringBuf("TEXT"); + o << TStringBuf("TEXT"); return; case EFormat::PROMETHEUS: - o << TStringBuf("PROMETHEUS"); + o << TStringBuf("PROMETHEUS"); return; case EFormat::UNKNOWN: - o << TStringBuf("UNKNOWN"); + o << TStringBuf("UNKNOWN"); return; } @@ -163,15 +163,15 @@ template <> NMonitoring::ECompression FromStringImpl<NMonitoring::ECompression>(const char* str, size_t len) { using NMonitoring::ECompression; TStringBuf value(str, len); - if (value == TStringBuf("IDENTITY")) { + if (value == TStringBuf("IDENTITY")) { return ECompression::IDENTITY; - } else if (value == TStringBuf("ZLIB")) { + } else if (value == TStringBuf("ZLIB")) { return ECompression::ZLIB; - } else if (value == TStringBuf("LZ4")) { + } else if (value == TStringBuf("LZ4")) { return ECompression::LZ4; - } else if (value == TStringBuf("ZSTD")) { + } else if (value == TStringBuf("ZSTD")) { return ECompression::ZSTD; - } else if (value == TStringBuf("UNKNOWN")) { + } else if (value == TStringBuf("UNKNOWN")) { return ECompression::UNKNOWN; } ythrow yexception() << "unknown compression: " << value; @@ -182,19 +182,19 @@ void Out<NMonitoring::ECompression>(IOutputStream& o, NMonitoring::ECompression using NMonitoring::ECompression; switch (c) { case ECompression::IDENTITY: - o << TStringBuf("IDENTITY"); + o << TStringBuf("IDENTITY"); return; case ECompression::ZLIB: - o << TStringBuf("ZLIB"); + o << TStringBuf("ZLIB"); return; case ECompression::LZ4: - o << TStringBuf("LZ4"); + o << TStringBuf("LZ4"); return; case ECompression::ZSTD: - o << TStringBuf("ZSTD"); + o << TStringBuf("ZSTD"); return; case ECompression::UNKNOWN: - o << TStringBuf("UNKNOWN"); + o << TStringBuf("UNKNOWN"); return; } diff --git a/library/cpp/monlib/encode/format.h b/library/cpp/monlib/encode/format.h index 495d42d786..d0e2143e3a 100644 --- a/library/cpp/monlib/encode/format.h +++ b/library/cpp/monlib/encode/format.h @@ -4,18 +4,18 @@ namespace NMonitoring { namespace NFormatContenType { - constexpr TStringBuf TEXT = "application/x-solomon-txt"; - constexpr TStringBuf JSON = "application/json"; - constexpr TStringBuf PROTOBUF = "application/x-solomon-pb"; - constexpr TStringBuf SPACK = "application/x-solomon-spack"; - constexpr TStringBuf PROMETHEUS = "text/plain"; + constexpr TStringBuf TEXT = "application/x-solomon-txt"; + constexpr TStringBuf JSON = "application/json"; + constexpr TStringBuf PROTOBUF = "application/x-solomon-pb"; + constexpr TStringBuf SPACK = "application/x-solomon-spack"; + constexpr TStringBuf PROMETHEUS = "text/plain"; } namespace NFormatContentEncoding { - constexpr TStringBuf IDENTITY = "identity"; - constexpr TStringBuf ZLIB = "zlib"; - constexpr TStringBuf LZ4 = "lz4"; - constexpr TStringBuf ZSTD = "zstd"; + constexpr TStringBuf IDENTITY = "identity"; + constexpr TStringBuf ZLIB = "zlib"; + constexpr TStringBuf LZ4 = "lz4"; + constexpr TStringBuf ZSTD = "zstd"; } /** diff --git a/library/cpp/monlib/encode/json/json_decoder.cpp b/library/cpp/monlib/encode/json/json_decoder.cpp index d44ff5fd28..8777caa021 100644 --- a/library/cpp/monlib/encode/json/json_decoder.cpp +++ b/library/cpp/monlib/encode/json/json_decoder.cpp @@ -172,11 +172,11 @@ private: }; std::pair<double, bool> ParseSpecDouble(TStringBuf string) { - if (string == TStringBuf("nan") || string == TStringBuf("NaN")) { + if (string == TStringBuf("nan") || string == TStringBuf("NaN")) { return {std::numeric_limits<double>::quiet_NaN(), true}; - } else if (string == TStringBuf("inf") || string == TStringBuf("Infinity")) { + } else if (string == TStringBuf("inf") || string == TStringBuf("Infinity")) { return {std::numeric_limits<double>::infinity(), true}; - } else if (string == TStringBuf("-inf") || string == TStringBuf("-Infinity")) { + } else if (string == TStringBuf("-inf") || string == TStringBuf("-Infinity")) { return {-std::numeric_limits<double>::infinity(), true}; } else { return {0, false}; @@ -762,7 +762,7 @@ if (Y_UNLIKELY(!(CONDITION))) { \ break; case TState::METRIC_MODE: - if (value == TStringBuf("deriv")) { + if (value == TStringBuf("deriv")) { LastMetric_.Type = EMetricType::RATE; } State_.ToPrev(); @@ -814,11 +814,11 @@ if (Y_UNLIKELY(!(CONDITION))) { \ bool OnMapKey(const TStringBuf& key) override { switch (State_.Current()) { case TState::ROOT_OBJECT: - if (key == TStringBuf("commonLabels") || key == TStringBuf("labels")) { + if (key == TStringBuf("commonLabels") || key == TStringBuf("labels")) { State_.ToNext(TState::COMMON_LABELS); - } else if (key == TStringBuf("ts")) { + } else if (key == TStringBuf("ts")) { State_.ToNext(TState::COMMON_TS); - } else if (key == TStringBuf("sensors") || key == TStringBuf("metrics")) { + } else if (key == TStringBuf("sensors") || key == TStringBuf("metrics")) { State_.ToNext(TState::METRICS_ARRAY); } break; @@ -829,36 +829,36 @@ if (Y_UNLIKELY(!(CONDITION))) { \ break; case TState::METRIC_OBJECT: - if (key == TStringBuf("labels")) { + if (key == TStringBuf("labels")) { State_.ToNext(TState::METRIC_LABELS); } else if (key == TStringBuf("name")) { State_.ToNext(TState::METRIC_NAME); - } else if (key == TStringBuf("ts")) { + } else if (key == TStringBuf("ts")) { PARSE_ENSURE(!LastMetric_.SeenTimeseries, "mixed timeseries and ts attributes"); LastMetric_.SeenTsOrValue = true; State_.ToNext(TState::METRIC_TS); - } else if (key == TStringBuf("value")) { + } else if (key == TStringBuf("value")) { PARSE_ENSURE(!LastMetric_.SeenTimeseries, "mixed timeseries and value attributes"); LastMetric_.SeenTsOrValue = true; State_.ToNext(TState::METRIC_VALUE); - } else if (key == TStringBuf("timeseries")) { + } else if (key == TStringBuf("timeseries")) { PARSE_ENSURE(!LastMetric_.SeenTsOrValue, "mixed timeseries and ts/value attributes"); LastMetric_.SeenTimeseries = true; State_.ToNext(TState::METRIC_TIMESERIES); - } else if (key == TStringBuf("mode")) { + } else if (key == TStringBuf("mode")) { State_.ToNext(TState::METRIC_MODE); - } else if (key == TStringBuf("kind") || key == TStringBuf("type")) { + } else if (key == TStringBuf("kind") || key == TStringBuf("type")) { State_.ToNext(TState::METRIC_TYPE); - } else if (key == TStringBuf("hist")) { + } else if (key == TStringBuf("hist")) { State_.ToNext(TState::METRIC_HIST); - } else if (key == TStringBuf("summary")) { + } else if (key == TStringBuf("summary")) { State_.ToNext(TState::METRIC_DSUMMARY); - } else if (key == TStringBuf("log_hist")) { + } else if (key == TStringBuf("log_hist")) { State_.ToNext(TState::METRIC_LOG_HIST); - } else if (key == TStringBuf("memOnly")) { + } else if (key == TStringBuf("memOnly")) { // deprecated. Skip it without errors for backward compatibility } else { ErrorMsg_ = TStringBuilder() << "unexpected key \"" << key << "\" in a metric schema"; @@ -867,51 +867,51 @@ if (Y_UNLIKELY(!(CONDITION))) { \ break; case TState::METRIC_TIMESERIES: - if (key == TStringBuf("ts")) { + if (key == TStringBuf("ts")) { State_.ToNext(TState::METRIC_TS); - } else if (key == TStringBuf("value")) { + } else if (key == TStringBuf("value")) { State_.ToNext(TState::METRIC_VALUE); - } else if (key == TStringBuf("hist")) { + } else if (key == TStringBuf("hist")) { State_.ToNext(TState::METRIC_HIST); - } else if (key == TStringBuf("summary")) { + } else if (key == TStringBuf("summary")) { State_.ToNext(TState::METRIC_DSUMMARY); - } else if (key == TStringBuf("log_hist")) { + } else if (key == TStringBuf("log_hist")) { State_.ToNext(TState::METRIC_LOG_HIST); } break; case TState::METRIC_HIST: - if (key == TStringBuf("bounds")) { + if (key == TStringBuf("bounds")) { State_.ToNext(TState::METRIC_HIST_BOUNDS); - } else if (key == TStringBuf("buckets")) { + } else if (key == TStringBuf("buckets")) { State_.ToNext(TState::METRIC_HIST_BUCKETS); - } else if (key == TStringBuf("inf")) { + } else if (key == TStringBuf("inf")) { State_.ToNext(TState::METRIC_HIST_INF); } break; case TState::METRIC_LOG_HIST: - if (key == TStringBuf("base")) { + if (key == TStringBuf("base")) { State_.ToNext(TState::METRIC_LOG_HIST_BASE); - } else if (key == TStringBuf("zeros_count")) { + } else if (key == TStringBuf("zeros_count")) { State_.ToNext(TState::METRIC_LOG_HIST_ZEROS); - } else if (key == TStringBuf("start_power")) { + } else if (key == TStringBuf("start_power")) { State_.ToNext(TState::METRIC_LOG_HIST_START_POWER); - } else if (key == TStringBuf("buckets")) { + } else if (key == TStringBuf("buckets")) { State_.ToNext(TState::METRIC_LOG_HIST_BUCKETS); } break; case TState::METRIC_DSUMMARY: - if (key == TStringBuf("sum")) { + if (key == TStringBuf("sum")) { State_.ToNext(TState::METRIC_DSUMMARY_SUM); - } else if (key == TStringBuf("min")) { + } else if (key == TStringBuf("min")) { State_.ToNext(TState::METRIC_DSUMMARY_MIN); - } else if (key == TStringBuf("max")) { + } else if (key == TStringBuf("max")) { State_.ToNext(TState::METRIC_DSUMMARY_MAX); - } else if (key == TStringBuf("last")) { + } else if (key == TStringBuf("last")) { State_.ToNext(TState::METRIC_DSUMMARY_LAST); - } else if (key == TStringBuf("count")) { + } else if (key == TStringBuf("count")) { State_.ToNext(TState::METRIC_DSUMMARY_COUNT); } diff --git a/library/cpp/monlib/encode/json/json_decoder_ut.cpp b/library/cpp/monlib/encode/json/json_decoder_ut.cpp index 4464e1d26a..6c047f96e5 100644 --- a/library/cpp/monlib/encode/json/json_decoder_ut.cpp +++ b/library/cpp/monlib/encode/json/json_decoder_ut.cpp @@ -15,15 +15,15 @@ enum EJsonPart : ui8 { }; constexpr std::array<TStringBuf, 3> JSON_PARTS = { - TStringBuf(R"("metrics": [{ + TStringBuf(R"("metrics": [{ "labels": { "key": "value" }, "type": "GAUGE", "value": 123 }])"), - TStringBuf(R"("ts": 1)"), + TStringBuf(R"("ts": 1)"), - TStringBuf(R"("commonLabels": { + TStringBuf(R"("commonLabels": { "key1": "value1", "key2": "value2" })"), @@ -52,10 +52,10 @@ void ValidateCommonParts(TCommonParts&& commonParts, bool checkLabels, bool chec if (checkLabels) { auto& labels = commonParts.CommonLabels; UNIT_ASSERT_VALUES_EQUAL(labels.Size(), 2); - UNIT_ASSERT(labels.Has(TStringBuf("key1"))); - UNIT_ASSERT(labels.Has(TStringBuf("key2"))); - UNIT_ASSERT_VALUES_EQUAL(labels.Get(TStringBuf("key1")).value()->Value(), "value1"); - UNIT_ASSERT_VALUES_EQUAL(labels.Get(TStringBuf("key2")).value()->Value(), "value2"); + UNIT_ASSERT(labels.Has(TStringBuf("key1"))); + UNIT_ASSERT(labels.Has(TStringBuf("key2"))); + UNIT_ASSERT_VALUES_EQUAL(labels.Get(TStringBuf("key1")).value()->Value(), "value1"); + UNIT_ASSERT_VALUES_EQUAL(labels.Get(TStringBuf("key2")).value()->Value(), "value2"); } } diff --git a/library/cpp/monlib/encode/json/json_encoder.cpp b/library/cpp/monlib/encode/json/json_encoder.cpp index 20d2bb6283..7a6d6406e7 100644 --- a/library/cpp/monlib/encode/json/json_encoder.cpp +++ b/library/cpp/monlib/encode/json/json_encoder.cpp @@ -36,7 +36,7 @@ namespace NMonitoring { void WriteTime(TInstant time) { if (time != TInstant::Zero()) { - Buf_.WriteKey(TStringBuf("ts")); + Buf_.WriteKey(TStringBuf("ts")); if (Style_ == EJsonStyle::Solomon) { Buf_.WriteULongLong(time.Seconds()); } else { @@ -46,24 +46,24 @@ namespace NMonitoring { } void WriteValue(double value) { - Buf_.WriteKey(TStringBuf("value")); + Buf_.WriteKey(TStringBuf("value")); Buf_.WriteDouble(value); } void WriteValue(i64 value) { - Buf_.WriteKey(TStringBuf("value")); + Buf_.WriteKey(TStringBuf("value")); Buf_.WriteLongLong(value); } void WriteValue(ui64 value) { - Buf_.WriteKey(TStringBuf("value")); + Buf_.WriteKey(TStringBuf("value")); Buf_.WriteULongLong(value); } void WriteValue(IHistogramSnapshot* s) { Y_ENSURE(Style_ == EJsonStyle::Solomon); - Buf_.WriteKey(TStringBuf("hist")); + Buf_.WriteKey(TStringBuf("hist")); Buf_.BeginObject(); if (ui32 count = s->Count()) { bool hasInf = (s->UpperBound(count - 1) == Max<double>()); @@ -71,14 +71,14 @@ namespace NMonitoring { count--; } - Buf_.WriteKey(TStringBuf("bounds")); + Buf_.WriteKey(TStringBuf("bounds")); Buf_.BeginList(); for (ui32 i = 0; i < count; i++) { Buf_.WriteDouble(s->UpperBound(i)); } Buf_.EndList(); - Buf_.WriteKey(TStringBuf("buckets")); + Buf_.WriteKey(TStringBuf("buckets")); Buf_.BeginList(); for (ui32 i = 0; i < count; i++) { Buf_.WriteULongLong(s->Value(i)); @@ -86,7 +86,7 @@ namespace NMonitoring { Buf_.EndList(); if (hasInf) { - Buf_.WriteKey(TStringBuf("inf")); + Buf_.WriteKey(TStringBuf("inf")); Buf_.WriteULongLong(s->Value(count)); } } @@ -96,22 +96,22 @@ namespace NMonitoring { void WriteValue(ISummaryDoubleSnapshot* s) { Y_ENSURE(Style_ == EJsonStyle::Solomon); - Buf_.WriteKey(TStringBuf("summary")); + Buf_.WriteKey(TStringBuf("summary")); Buf_.BeginObject(); - Buf_.WriteKey(TStringBuf("sum")); + Buf_.WriteKey(TStringBuf("sum")); Buf_.WriteDouble(s->GetSum()); - Buf_.WriteKey(TStringBuf("min")); + Buf_.WriteKey(TStringBuf("min")); Buf_.WriteDouble(s->GetMin()); - Buf_.WriteKey(TStringBuf("max")); + Buf_.WriteKey(TStringBuf("max")); Buf_.WriteDouble(s->GetMax()); - Buf_.WriteKey(TStringBuf("last")); + Buf_.WriteKey(TStringBuf("last")); Buf_.WriteDouble(s->GetLast()); - Buf_.WriteKey(TStringBuf("count")); + Buf_.WriteKey(TStringBuf("count")); Buf_.WriteULongLong(s->GetCount()); Buf_.EndObject(); @@ -120,19 +120,19 @@ namespace NMonitoring { void WriteValue(TLogHistogramSnapshot* s) { Y_ENSURE(Style_ == EJsonStyle::Solomon); - Buf_.WriteKey(TStringBuf("log_hist")); + Buf_.WriteKey(TStringBuf("log_hist")); Buf_.BeginObject(); - Buf_.WriteKey(TStringBuf("base")); + Buf_.WriteKey(TStringBuf("base")); Buf_.WriteDouble(s->Base()); - Buf_.WriteKey(TStringBuf("zeros_count")); + Buf_.WriteKey(TStringBuf("zeros_count")); Buf_.WriteULongLong(s->ZerosCount()); - Buf_.WriteKey(TStringBuf("start_power")); + Buf_.WriteKey(TStringBuf("start_power")); Buf_.WriteInt(s->StartPower()); - Buf_.WriteKey(TStringBuf("buckets")); + Buf_.WriteKey(TStringBuf("buckets")); Buf_.BeginList(); for (size_t i = 0; i < s->Count(); ++i) { Buf_.WriteDouble(s->Bucket(i)); @@ -239,7 +239,7 @@ namespace NMonitoring { { } - ~TEncoderJson() override { + ~TEncoderJson() override { Close(); } @@ -303,7 +303,7 @@ namespace NMonitoring { Buf_.WriteKey(TStringBuf(Style_ == EJsonStyle::Solomon ? "commonLabels" : "labels")); } else if (State_ == TEncoderState::EState::METRIC) { State_ = TEncoderState::EState::METRIC_LABELS; - Buf_.WriteKey(TStringBuf("labels")); + Buf_.WriteKey(TStringBuf("labels")); } else { State_.ThrowInvalid("expected METRIC or ROOT"); } @@ -381,7 +381,7 @@ namespace NMonitoring { "mixed metric value types in one metric"); if (!TimeSeries_) { - Buf_.WriteKey(TStringBuf("timeseries")); + Buf_.WriteKey(TStringBuf("timeseries")); Buf_.BeginList(); Buf_.BeginObject(); Y_ENSURE(LastPoint_.GetTime() != TInstant::Zero(), @@ -426,7 +426,7 @@ namespace NMonitoring { MetricsMergingMode_ = EMetricsMergingMode::MERGE_METRICS; } - ~TBufferedJsonEncoder() override { + ~TBufferedJsonEncoder() override { Close(); } @@ -490,7 +490,7 @@ namespace NMonitoring { WriteMetricType(metric.MetricType); - Buf_.WriteKey(TStringBuf("labels")); + Buf_.WriteKey(TStringBuf("labels")); WriteLabels(metric.Labels, false); metric.TimeSeries.SortByTs(); @@ -499,7 +499,7 @@ namespace NMonitoring { WriteTime(point.GetTime()); WriteValue(metric.TimeSeries.GetValueType(), point.GetValue()); } else if (metric.TimeSeries.Size() > 1) { - Buf_.WriteKey(TStringBuf("timeseries")); + Buf_.WriteKey(TStringBuf("timeseries")); Buf_.BeginList(); metric.TimeSeries.ForEach([this](TInstant time, EMetricValueType type, TMetricValue value) { Buf_.BeginObject(); diff --git a/library/cpp/monlib/encode/legacy_protobuf/legacy_proto_decoder.cpp b/library/cpp/monlib/encode/legacy_protobuf/legacy_proto_decoder.cpp index f87a2d7e8f..f74cade8e8 100644 --- a/library/cpp/monlib/encode/legacy_protobuf/legacy_proto_decoder.cpp +++ b/library/cpp/monlib/encode/legacy_protobuf/legacy_proto_decoder.cpp @@ -163,10 +163,10 @@ namespace NMonitoring { TRACE("found fixed label " << l); } - EType Type() const override { + EType Type() const override { return EType::Fixed; } - TLabel Get(const NProtoBuf::Message&) override { + TLabel Get(const NProtoBuf::Message&) override { return Label_; } @@ -184,10 +184,10 @@ namespace NMonitoring { TRACE("found lazy label"); } - EType Type() const override { + EType Type() const override { return EType::Lazy; } - TLabel Get(const NProtoBuf::Message& msg) override { + TLabel Get(const NProtoBuf::Message& msg) override { return Fn_(msg); } @@ -289,7 +289,7 @@ namespace NMonitoring { TStringBuf lhs, rhs; const bool isDynamic = str.TrySplit(':', lhs, rhs); - const bool isIndexing = isDynamic && rhs == TStringBuf("#"); + const bool isIndexing = isDynamic && rhs == TStringBuf("#"); if (isIndexing) { TRACE("parsed index labels"); diff --git a/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp b/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp index 7e81357dbd..0cdecebcfa 100644 --- a/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp +++ b/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp @@ -22,7 +22,7 @@ namespace NMonitoring { namespace { - constexpr ui32 MAX_LABEL_VALUE_LEN = 256; + constexpr ui32 MAX_LABEL_VALUE_LEN = 256; using TLabelsMap = THashMap<TString, TString>; @@ -225,7 +225,7 @@ namespace NMonitoring { SkipSpaces(); TStringBuf keyword = ReadToken(); - if (keyword == TStringBuf("TYPE")) { + if (keyword == TStringBuf("TYPE")) { SkipSpaces(); TStringBuf nextName = ReadTokenAsMetricName(); @@ -561,11 +561,11 @@ namespace NMonitoring { } double ParseGoDouble(TStringBuf str) { - if (str == TStringBuf("+Inf")) { + if (str == TStringBuf("+Inf")) { return std::numeric_limits<double>::infinity(); - } else if (str == TStringBuf("-Inf")) { + } else if (str == TStringBuf("-Inf")) { return -std::numeric_limits<double>::infinity(); - } else if (str == TStringBuf("NaN")) { + } else if (str == TStringBuf("NaN")) { return NAN; } diff --git a/library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp b/library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp index 15efeb8c03..7eee2d709d 100644 --- a/library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp +++ b/library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp @@ -71,7 +71,7 @@ namespace NMonitoring { TBucketBound bound = h->UpperBound(i); TStringBuf boundStr; if (bound == HISTOGRAM_INF_BOUND) { - boundStr = TStringBuf("+Inf"); + boundStr = TStringBuf("+Inf"); } else { size_t len = FloatToString(bound, TmpBuf_, Y_ARRAY_SIZE(TmpBuf_)); boundStr = TStringBuf(TmpBuf_, len); diff --git a/library/cpp/monlib/encode/prometheus/prometheus_model.h b/library/cpp/monlib/encode/prometheus/prometheus_model.h index cb7f2cb15b..377934f8b4 100644 --- a/library/cpp/monlib/encode/prometheus/prometheus_model.h +++ b/library/cpp/monlib/encode/prometheus/prometheus_model.h @@ -13,16 +13,16 @@ namespace NPrometheus { // and https://github.com/prometheus/common/blob/master/expfmt/text_parse.go // - inline constexpr TStringBuf BUCKET_SUFFIX = "_bucket"; - inline constexpr TStringBuf COUNT_SUFFIX = "_count"; - inline constexpr TStringBuf SUM_SUFFIX = "_sum"; - inline constexpr TStringBuf MIN_SUFFIX = "_min"; - inline constexpr TStringBuf MAX_SUFFIX = "_max"; - inline constexpr TStringBuf LAST_SUFFIX = "_last"; + inline constexpr TStringBuf BUCKET_SUFFIX = "_bucket"; + inline constexpr TStringBuf COUNT_SUFFIX = "_count"; + inline constexpr TStringBuf SUM_SUFFIX = "_sum"; + inline constexpr TStringBuf MIN_SUFFIX = "_min"; + inline constexpr TStringBuf MAX_SUFFIX = "_max"; + inline constexpr TStringBuf LAST_SUFFIX = "_last"; // Used for the label that defines the upper bound of a bucket of a // histogram ("le" -> "less or equal"). - inline constexpr TStringBuf BUCKET_LABEL = "le"; + inline constexpr TStringBuf BUCKET_LABEL = "le"; inline bool IsValidLabelNameStart(char ch) { diff --git a/library/cpp/monlib/encode/protobuf/protobuf_encoder.cpp b/library/cpp/monlib/encode/protobuf/protobuf_encoder.cpp index 2d11b9d5ba..1b4a1a23b4 100644 --- a/library/cpp/monlib/encode/protobuf/protobuf_encoder.cpp +++ b/library/cpp/monlib/encode/protobuf/protobuf_encoder.cpp @@ -213,7 +213,7 @@ namespace NMonitoring { FillHistogram(*snapshot, point->MutableHistogram()); } - void OnSummaryDouble(TInstant time, ISummaryDoubleSnapshotPtr snapshot) override { + void OnSummaryDouble(TInstant time, ISummaryDoubleSnapshotPtr snapshot) override { Y_ENSURE(Sample_, "metric not started"); NProto::TPoint* point = Sample_->AddPoints(); point->SetTime(time.MilliSeconds()); diff --git a/library/cpp/monlib/encode/spack/compression.cpp b/library/cpp/monlib/encode/spack/compression.cpp index 0d2152fc85..d7223203ad 100644 --- a/library/cpp/monlib/encode/spack/compression.cpp +++ b/library/cpp/monlib/encode/spack/compression.cpp @@ -124,7 +124,7 @@ namespace NMonitoring { static size_t Compress(TBlock in, TBlock out) { size_t rc = ZSTD_compress(out.data(), out.size(), in.data(), in.size(), LEVEL); if (Y_UNLIKELY(ZSTD_isError(rc))) { - ythrow yexception() << TStringBuf("zstd compression failed: ") + ythrow yexception() << TStringBuf("zstd compression failed: ") << ZSTD_getErrorName(rc); } return rc; @@ -133,7 +133,7 @@ namespace NMonitoring { static void Decompress(TBlock in, TBlock out) { size_t rc = ZSTD_decompress(out.data(), out.size(), in.data(), in.size()); if (Y_UNLIKELY(ZSTD_isError(rc))) { - ythrow yexception() << TStringBuf("zstd decompression failed: ") + ythrow yexception() << TStringBuf("zstd decompression failed: ") << ZSTD_getErrorName(rc); } Y_ENSURE(rc == out.size(), "zstd decompressed wrong size"); @@ -249,7 +249,7 @@ namespace NMonitoring { { } - ~TFramedCompressStream() override { + ~TFramedCompressStream() override { try { Finish(); } catch (...) { diff --git a/library/cpp/monlib/encode/spack/spack_v1_encoder.cpp b/library/cpp/monlib/encode/spack/spack_v1_encoder.cpp index a2b0bb5f50..7d5766d728 100644 --- a/library/cpp/monlib/encode/spack/spack_v1_encoder.cpp +++ b/library/cpp/monlib/encode/spack/spack_v1_encoder.cpp @@ -39,7 +39,7 @@ namespace NMonitoring { LabelValuesPool_.SetSorted(true); } - ~TEncoderSpackV1() override { + ~TEncoderSpackV1() override { Close(); } diff --git a/library/cpp/monlib/encode/text/text_encoder.cpp b/library/cpp/monlib/encode/text/text_encoder.cpp index 10336261f0..e60caf2144 100644 --- a/library/cpp/monlib/encode/text/text_encoder.cpp +++ b/library/cpp/monlib/encode/text/text_encoder.cpp @@ -30,7 +30,7 @@ namespace NMonitoring { State_.Expect(TEncoderState::EState::ROOT); CommonTime_ = time; if (time != TInstant::Zero()) { - Out_->Write(TStringBuf("common time: ")); + Out_->Write(TStringBuf("common time: ")); WriteTime(time); Out_->Write('\n'); } @@ -62,7 +62,7 @@ namespace NMonitoring { State_ = TEncoderState::EState::METRIC; } else if (State_ == TEncoderState::EState::COMMON_LABELS) { State_ = TEncoderState::EState::ROOT; - Out_->Write(TStringBuf("common labels: ")); + Out_->Write(TStringBuf("common labels: ")); WriteLabels(); Out_->Write('\n'); } else { @@ -149,11 +149,11 @@ namespace NMonitoring { out << '{'; for (auto&& l : Labels_) { - out << l.Name() << TStringBuf("='") << l.Value() << '\''; + out << l.Name() << TStringBuf("='") << l.Value() << '\''; ++i; if (i < size) { - out << TStringBuf(", "); + out << TStringBuf(", "); } }; @@ -166,7 +166,7 @@ namespace NMonitoring { (*Out_) << LeftPad(typeStr, MaxMetricTypeNameLength) << ' '; // (2) name and labels - auto name = Labels_.Extract(TStringBuf("sensor")); + auto name = Labels_.Extract(TStringBuf("sensor")); if (name) { if (name->Value().find(' ') != TString::npos) { (*Out_) << '"' << name->Value() << '"'; @@ -179,10 +179,10 @@ namespace NMonitoring { // (3) values if (!TimeSeries_.Empty()) { TimeSeries_.SortByTs(); - Out_->Write(TStringBuf(" [")); + Out_->Write(TStringBuf(" [")); for (size_t i = 0; i < TimeSeries_.Size(); i++) { if (i > 0) { - Out_->Write(TStringBuf(", ")); + Out_->Write(TStringBuf(", ")); } const auto& point = TimeSeries_[i]; @@ -191,7 +191,7 @@ namespace NMonitoring { } else { Out_->Write('('); WriteTime(point.GetTime()); - Out_->Write(TStringBuf(", ")); + Out_->Write(TStringBuf(", ")); WriteValue(TimeSeries_.GetValueType(), point.GetValue()); Out_->Write(')'); } diff --git a/library/cpp/monlib/encode/unistat/unistat_decoder.cpp b/library/cpp/monlib/encode/unistat/unistat_decoder.cpp index b2344b0905..7497ae1f79 100644 --- a/library/cpp/monlib/encode/unistat/unistat_decoder.cpp +++ b/library/cpp/monlib/encode/unistat/unistat_decoder.cpp @@ -156,9 +156,9 @@ namespace NMonitoring { Y_ENSURE(suffix.size() >= 3 && suffix.size() <= 5, "Disallowed suffix value: " << suffix); - if (suffix == TStringBuf("summ") || suffix == TStringBuf("hgram")) { + if (suffix == TStringBuf("summ") || suffix == TStringBuf("hgram")) { return true; - } else if (suffix == TStringBuf("max")) { + } else if (suffix == TStringBuf("max")) { return false; } diff --git a/library/cpp/monlib/encode/unistat/unistat_ut.cpp b/library/cpp/monlib/encode/unistat/unistat_ut.cpp index dbbc238bf3..7da071a587 100644 --- a/library/cpp/monlib/encode/unistat/unistat_ut.cpp +++ b/library/cpp/monlib/encode/unistat/unistat_ut.cpp @@ -9,7 +9,7 @@ using namespace NMonitoring; Y_UNIT_TEST_SUITE(TUnistatDecoderTest) { Y_UNIT_TEST(ScalarMetric) { - constexpr auto input = TStringBuf(R"([["something_axxx", 42]])"); + constexpr auto input = TStringBuf(R"([["something_axxx", 42]])"); NProto::TMultiSamplesList samples; auto encoder = EncoderProtobuf(&samples); @@ -57,7 +57,7 @@ Y_UNIT_TEST_SUITE(TUnistatDecoderTest) { } Y_UNIT_TEST(ThrowsOnTopLevelObject) { - constexpr auto input = TStringBuf(R"({["something_axxx", 42]})"); + constexpr auto input = TStringBuf(R"({["something_axxx", 42]})"); NProto::TMultiSamplesList samples; auto encoder = EncoderProtobuf(&samples); @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(TUnistatDecoderTest) { } Y_UNIT_TEST(ThrowsOnUnwrappedMetric) { - constexpr auto input = TStringBuf(R"(["something_axxx", 42])"); + constexpr auto input = TStringBuf(R"(["something_axxx", 42])"); NProto::TMultiSamplesList samples; auto encoder = EncoderProtobuf(&samples); @@ -75,7 +75,7 @@ Y_UNIT_TEST_SUITE(TUnistatDecoderTest) { } Y_UNIT_TEST(HistogramMetric) { - constexpr auto input = TStringBuf(R"([["something_hgram", [[0, 1], [200, 2], [500, 3]] ]])"); + constexpr auto input = TStringBuf(R"([["something_hgram", [[0, 1], [200, 2], [500, 3]] ]])"); NProto::TMultiSamplesList samples; auto encoder = EncoderProtobuf(&samples); @@ -106,7 +106,7 @@ Y_UNIT_TEST_SUITE(TUnistatDecoderTest) { } Y_UNIT_TEST(AbsoluteHistogram) { - constexpr auto input = TStringBuf(R"([["something_ahhh", [[0, 1], [200, 2], [500, 3]] ]])"); + constexpr auto input = TStringBuf(R"([["something_ahhh", [[0, 1], [200, 2], [500, 3]] ]])"); NProto::TMultiSamplesList samples; auto encoder = EncoderProtobuf(&samples); @@ -134,23 +134,23 @@ Y_UNIT_TEST_SUITE(TUnistatDecoderTest) { auto encoder = EncoderProtobuf(&samples); { - constexpr auto input = TStringBuf(R"([["someth!ng_ahhh", [[0, 1], [200, 2], [500, 3]] ]])"); + constexpr auto input = TStringBuf(R"([["someth!ng_ahhh", [[0, 1], [200, 2], [500, 3]] ]])"); UNIT_ASSERT_EXCEPTION(DecodeUnistat(input, encoder.Get()), yexception); } { - constexpr auto input = TStringBuf(R"([["foo_a", [[0, 1], [200, 2], [500, 3]] ]])"); + constexpr auto input = TStringBuf(R"([["foo_a", [[0, 1], [200, 2], [500, 3]] ]])"); UNIT_ASSERT_EXCEPTION(DecodeUnistat(input, encoder.Get()), yexception); } { - constexpr auto input = TStringBuf(R"([["foo_ahhh;tag=value", [[0, 1], [200, 2], [500, 3]] ]])"); + constexpr auto input = TStringBuf(R"([["foo_ahhh;tag=value", [[0, 1], [200, 2], [500, 3]] ]])"); UNIT_ASSERT_EXCEPTION(DecodeUnistat(input, encoder.Get()), yexception); } } Y_UNIT_TEST(MultipleMetrics) { - constexpr auto input = TStringBuf(R"([["something_axxx", 42], ["some-other_dhhh", 53]])"); + constexpr auto input = TStringBuf(R"([["something_axxx", 42], ["some-other_dhhh", 53]])"); NProto::TMultiSamplesList samples; auto encoder = EncoderProtobuf(&samples); @@ -182,7 +182,7 @@ Y_UNIT_TEST_SUITE(TUnistatDecoderTest) { } Y_UNIT_TEST(UnderscoreName) { - constexpr auto input = TStringBuf(R"([["something_anything_dmmm", 42]])"); + constexpr auto input = TStringBuf(R"([["something_anything_dmmm", 42]])"); NProto::TMultiSamplesList samples; auto encoder = EncoderProtobuf(&samples); @@ -202,7 +202,7 @@ Y_UNIT_TEST_SUITE(TUnistatDecoderTest) { } Y_UNIT_TEST(MaxAggr) { - constexpr auto input = TStringBuf(R"([["something_anything_max", 42]])"); + constexpr auto input = TStringBuf(R"([["something_anything_max", 42]])"); NProto::TMultiSamplesList samples; auto encoder = EncoderProtobuf(&samples); |