diff options
author | amatanhead <amatanhead@yandex-team.ru> | 2022-02-10 16:50:04 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:04 +0300 |
commit | b6f3a80f7c2c8b7dbb0c01b056fdc1fd8cd820e9 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/monlib | |
parent | 8879605a63ac17539be5b3bd41b529791f4d4b02 (diff) | |
download | ydb-b6f3a80f7c2c8b7dbb0c01b056fdc1fd8cd820e9.tar.gz |
Restoring authorship annotation for <amatanhead@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib')
-rw-r--r-- | library/cpp/monlib/encode/buffered/string_pool.h | 8 | ||||
-rw-r--r-- | library/cpp/monlib/encode/spack/spack_v1.h | 24 | ||||
-rw-r--r-- | library/cpp/monlib/encode/spack/spack_v1_decoder.cpp | 216 | ||||
-rw-r--r-- | library/cpp/monlib/encode/spack/varint.cpp | 26 | ||||
-rw-r--r-- | library/cpp/monlib/encode/spack/varint.h | 18 | ||||
-rw-r--r-- | library/cpp/monlib/metrics/metric_registry.cpp | 8 | ||||
-rw-r--r-- | library/cpp/monlib/metrics/metric_registry.h | 10 |
7 files changed, 155 insertions, 155 deletions
diff --git a/library/cpp/monlib/encode/buffered/string_pool.h b/library/cpp/monlib/encode/buffered/string_pool.h index 9d2f3216d7..00e5644608 100644 --- a/library/cpp/monlib/encode/buffered/string_pool.h +++ b/library/cpp/monlib/encode/buffered/string_pool.h @@ -78,10 +78,10 @@ namespace NMonitoring { return Index_.at(i); } - size_t Size() const { - return Index_.size(); - } - + size_t Size() const { + return Index_.size(); + } + private: void InitIndex(const char* data, ui32 size); diff --git a/library/cpp/monlib/encode/spack/spack_v1.h b/library/cpp/monlib/encode/spack/spack_v1.h index c417171f84..cf1c9417b9 100644 --- a/library/cpp/monlib/encode/spack/spack_v1.h +++ b/library/cpp/monlib/encode/spack/spack_v1.h @@ -24,9 +24,9 @@ namespace NMonitoring { EMetricType DecodeMetricType(ui8 byte); - [[nodiscard]] - bool TryDecodeMetricType(ui8 byte, EMetricType* result); - + [[nodiscard]] + bool TryDecodeMetricType(ui8 byte, EMetricType* result); + /////////////////////////////////////////////////////////////////////////////// // EValueType /////////////////////////////////////////////////////////////////////////////// @@ -43,9 +43,9 @@ namespace NMonitoring { EValueType DecodeValueType(ui8 byte); - [[nodiscard]] - bool TryDecodeValueType(ui8 byte, EValueType* result); - + [[nodiscard]] + bool TryDecodeValueType(ui8 byte, EValueType* result); + /////////////////////////////////////////////////////////////////////////////// // ETimePrecision /////////////////////////////////////////////////////////////////////////////// @@ -60,9 +60,9 @@ namespace NMonitoring { ETimePrecision DecodeTimePrecision(ui8 byte); - [[nodiscard]] - bool TryDecodeTimePrecision(ui8 byte, ETimePrecision* result); - + [[nodiscard]] + bool TryDecodeTimePrecision(ui8 byte, ETimePrecision* result); + /////////////////////////////////////////////////////////////////////////////// // ECompression /////////////////////////////////////////////////////////////////////////////// @@ -70,9 +70,9 @@ namespace NMonitoring { ECompression DecodeCompression(ui8 byte); - [[nodiscard]] - bool TryDecodeCompression(ui8 byte, ECompression* result); - + [[nodiscard]] + bool TryDecodeCompression(ui8 byte, ECompression* result); + /////////////////////////////////////////////////////////////////////////////// // TSpackHeader /////////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/monlib/encode/spack/spack_v1_decoder.cpp b/library/cpp/monlib/encode/spack/spack_v1_decoder.cpp index b188cbf7fa..1f445fc80d 100644 --- a/library/cpp/monlib/encode/spack/spack_v1_decoder.cpp +++ b/library/cpp/monlib/encode/spack/spack_v1_decoder.cpp @@ -284,119 +284,119 @@ namespace NMonitoring { } // namespace EValueType DecodeValueType(ui8 byte) { - EValueType result; - if (!TryDecodeValueType(byte, &result)) { + EValueType result; + if (!TryDecodeValueType(byte, &result)) { throw TSpackDecodeError() << "unknown value type: " << byte; - } - return result; - } - - bool TryDecodeValueType(ui8 byte, EValueType* result) { + } + return result; + } + + bool TryDecodeValueType(ui8 byte, EValueType* result) { if (byte == EncodeValueType(EValueType::NONE)) { - if (result) { - *result = EValueType::NONE; - } - return true; + if (result) { + *result = EValueType::NONE; + } + return true; } else if (byte == EncodeValueType(EValueType::ONE_WITHOUT_TS)) { - if (result) { - *result = EValueType::ONE_WITHOUT_TS; - } - return true; + if (result) { + *result = EValueType::ONE_WITHOUT_TS; + } + return true; } else if (byte == EncodeValueType(EValueType::ONE_WITH_TS)) { - if (result) { - *result = EValueType::ONE_WITH_TS; - } - return true; + if (result) { + *result = EValueType::ONE_WITH_TS; + } + return true; } else if (byte == EncodeValueType(EValueType::MANY_WITH_TS)) { - if (result) { - *result = EValueType::MANY_WITH_TS; - } - return true; + if (result) { + *result = EValueType::MANY_WITH_TS; + } + return true; } else { - return false; + return false; } } ETimePrecision DecodeTimePrecision(ui8 byte) { - ETimePrecision result; - if (!TryDecodeTimePrecision(byte, &result)) { + ETimePrecision result; + if (!TryDecodeTimePrecision(byte, &result)) { throw TSpackDecodeError() << "unknown time precision: " << byte; - } - return result; - } - - bool TryDecodeTimePrecision(ui8 byte, ETimePrecision* result) { + } + return result; + } + + bool TryDecodeTimePrecision(ui8 byte, ETimePrecision* result) { if (byte == EncodeTimePrecision(ETimePrecision::SECONDS)) { - if (result) { - *result = ETimePrecision::SECONDS; - } - return true; + if (result) { + *result = ETimePrecision::SECONDS; + } + return true; } else if (byte == EncodeTimePrecision(ETimePrecision::MILLIS)) { - if (result) { - *result = ETimePrecision::MILLIS; - } - return true; + if (result) { + *result = ETimePrecision::MILLIS; + } + return true; } else { - return false; + return false; } } EMetricType DecodeMetricType(ui8 byte) { - EMetricType result; - if (!TryDecodeMetricType(byte, &result)) { + EMetricType result; + if (!TryDecodeMetricType(byte, &result)) { throw TSpackDecodeError() << "unknown metric type: " << byte; - } - return result; - } - - bool TryDecodeMetricType(ui8 byte, EMetricType* result) { + } + return result; + } + + bool TryDecodeMetricType(ui8 byte, EMetricType* result) { if (byte == EncodeMetricType(EMetricType::GAUGE)) { - if (result) { - *result = EMetricType::GAUGE; - } - return true; + if (result) { + *result = EMetricType::GAUGE; + } + return true; } else if (byte == EncodeMetricType(EMetricType::COUNTER)) { - if (result) { - *result = EMetricType::COUNTER; - } - return true; + if (result) { + *result = EMetricType::COUNTER; + } + return true; } else if (byte == EncodeMetricType(EMetricType::RATE)) { - if (result) { - *result = EMetricType::RATE; - } - return true; + if (result) { + *result = EMetricType::RATE; + } + return true; } else if (byte == EncodeMetricType(EMetricType::IGAUGE)) { - if (result) { - *result = EMetricType::IGAUGE; - } - return true; + if (result) { + *result = EMetricType::IGAUGE; + } + return true; } else if (byte == EncodeMetricType(EMetricType::HIST)) { - if (result) { - *result = EMetricType::HIST; - } - return true; + if (result) { + *result = EMetricType::HIST; + } + return true; } else if (byte == EncodeMetricType(EMetricType::HIST_RATE)) { - if (result) { - *result = EMetricType::HIST_RATE; - } - return true; + if (result) { + *result = EMetricType::HIST_RATE; + } + return true; } else if (byte == EncodeMetricType(EMetricType::DSUMMARY)) { - if (result) { - *result = EMetricType::DSUMMARY; - } - return true; + if (result) { + *result = EMetricType::DSUMMARY; + } + return true; } else if (byte == EncodeMetricType(EMetricType::LOGHIST)) { - if (result) { - *result = EMetricType::LOGHIST; - } - return true; + if (result) { + *result = EMetricType::LOGHIST; + } + return true; } else if (byte == EncodeMetricType(EMetricType::UNKNOWN)) { - if (result) { - *result = EMetricType::UNKNOWN; - } - return true; + if (result) { + *result = EMetricType::UNKNOWN; + } + return true; } else { - return false; + return false; } } @@ -417,36 +417,36 @@ namespace NMonitoring { } ECompression DecodeCompression(ui8 byte) { - ECompression result; - if (!TryDecodeCompression(byte, &result)) { + ECompression result; + if (!TryDecodeCompression(byte, &result)) { throw TSpackDecodeError() << "unknown compression alg: " << byte; - } - return result; - } - - bool TryDecodeCompression(ui8 byte, ECompression* result) { + } + return result; + } + + bool TryDecodeCompression(ui8 byte, ECompression* result) { if (byte == EncodeCompression(ECompression::IDENTITY)) { - if (result) { - *result = ECompression::IDENTITY; - } - return true; + if (result) { + *result = ECompression::IDENTITY; + } + return true; } else if (byte == EncodeCompression(ECompression::ZLIB)) { - if (result) { - *result = ECompression::ZLIB; - } - return true; + if (result) { + *result = ECompression::ZLIB; + } + return true; } else if (byte == EncodeCompression(ECompression::ZSTD)) { - if (result) { - *result = ECompression::ZSTD; - } - return true; + if (result) { + *result = ECompression::ZSTD; + } + return true; } else if (byte == EncodeCompression(ECompression::LZ4)) { - if (result) { - *result = ECompression::LZ4; - } - return true; + if (result) { + *result = ECompression::LZ4; + } + return true; } else { - return false; + return false; } } diff --git a/library/cpp/monlib/encode/spack/varint.cpp b/library/cpp/monlib/encode/spack/varint.cpp index ea3aff9409..051cf17380 100644 --- a/library/cpp/monlib/encode/spack/varint.cpp +++ b/library/cpp/monlib/encode/spack/varint.cpp @@ -22,17 +22,17 @@ namespace NMonitoring { } ui32 ReadVarUInt32(IInputStream* input) { - ui32 value = 0; - switch (TryReadVarUInt32(input, &value)) { - case EReadResult::OK: - return value; - case EReadResult::ERR_OVERFLOW: + ui32 value = 0; + switch (TryReadVarUInt32(input, &value)) { + case EReadResult::OK: + return value; + case EReadResult::ERR_OVERFLOW: ythrow yexception() << "the data is too long to read ui32"; - case EReadResult::ERR_UNEXPECTED_EOF: + case EReadResult::ERR_UNEXPECTED_EOF: ythrow yexception() << "the data unexpectedly ended"; - default: - ythrow yexception() << "unknown error while reading varint"; - } + default: + ythrow yexception() << "unknown error while reading varint"; + } } size_t ReadVarUInt32(const ui8* buf, size_t len, ui32* result) { @@ -56,24 +56,24 @@ namespace NMonitoring { return count; } -EReadResult TryReadVarUInt32(IInputStream* input, ui32* value) { +EReadResult TryReadVarUInt32(IInputStream* input, ui32* value) { size_t count = 0; ui32 result = 0; ui8 byte = 0; do { if (7 * count > 8 * sizeof(ui32)) { - return EReadResult::ERR_OVERFLOW; + return EReadResult::ERR_OVERFLOW; } if (input->Read(&byte, 1) != 1) { - return EReadResult::ERR_UNEXPECTED_EOF; + return EReadResult::ERR_UNEXPECTED_EOF; } result |= (static_cast<ui32>(byte & 0x7F)) << (7 * count); ++count; } while (byte & 0x80); *value = result; - return EReadResult::OK; + return EReadResult::OK; } } diff --git a/library/cpp/monlib/encode/spack/varint.h b/library/cpp/monlib/encode/spack/varint.h index 7301fa3889..7ac522dd6c 100644 --- a/library/cpp/monlib/encode/spack/varint.h +++ b/library/cpp/monlib/encode/spack/varint.h @@ -11,13 +11,13 @@ namespace NMonitoring { ui32 ReadVarUInt32(IInputStream* input); size_t ReadVarUInt32(const ui8* buf, size_t len, ui32* result); - enum class EReadResult { - OK, - ERR_OVERFLOW, - ERR_UNEXPECTED_EOF, - }; - - [[nodiscard]] - EReadResult TryReadVarUInt32(IInputStream* input, ui32* value); - + enum class EReadResult { + OK, + ERR_OVERFLOW, + ERR_UNEXPECTED_EOF, + }; + + [[nodiscard]] + EReadResult TryReadVarUInt32(IInputStream* input, ui32* value); + } diff --git a/library/cpp/monlib/metrics/metric_registry.cpp b/library/cpp/monlib/metrics/metric_registry.cpp index f20b46dd36..b083163a7b 100644 --- a/library/cpp/monlib/metrics/metric_registry.cpp +++ b/library/cpp/monlib/metrics/metric_registry.cpp @@ -40,10 +40,10 @@ namespace NMonitoring { CommonLabels_ = commonLabels; } - TMetricRegistry* TMetricRegistry::Instance() { - return Singleton<TMetricRegistry>(); - } - + TMetricRegistry* TMetricRegistry::Instance() { + return Singleton<TMetricRegistry>(); + } + TGauge* TMetricRegistry::Gauge(TLabels labels) { return Metric<TGauge, EMetricType::GAUGE>(std::move(labels)); } diff --git a/library/cpp/monlib/metrics/metric_registry.h b/library/cpp/monlib/metrics/metric_registry.h index 725a4ec3ed..670cf8651e 100644 --- a/library/cpp/monlib/metrics/metric_registry.h +++ b/library/cpp/monlib/metrics/metric_registry.h @@ -57,11 +57,11 @@ namespace NMonitoring { explicit TMetricRegistry(const TLabels& commonLabels); - /** - * Get a global metrics registry instance. - */ - static TMetricRegistry* Instance(); - + /** + * Get a global metrics registry instance. + */ + static TMetricRegistry* Instance(); + TGauge* Gauge(TLabels labels); TLazyGauge* LazyGauge(TLabels labels, std::function<double()> supplier); TIntGauge* IntGauge(TLabels labels); |