diff options
author | msherbakov <msherbakov@yandex-team.ru> | 2022-02-10 16:49:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:17 +0300 |
commit | a0ffafe83b7d6229709a32fa942c71d672ac989c (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/monlib/encode/prometheus | |
parent | c224a621661ddd69699f9476922eb316607ef57e (diff) | |
download | ydb-a0ffafe83b7d6229709a32fa942c71d672ac989c.tar.gz |
Restoring authorship annotation for <msherbakov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/encode/prometheus')
-rw-r--r-- | library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp | 54 | ||||
-rw-r--r-- | library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp | 6 |
2 files changed, 30 insertions, 30 deletions
diff --git a/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp b/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp index 2195d9e125..7e81357dbd 100644 --- a/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp +++ b/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp @@ -46,24 +46,24 @@ namespace NMonitoring { return sb; } - template <typename T, typename U> - bool TryStaticCast(U val, T& out) { - static_assert(std::is_arithmetic_v<U>); + template <typename T, typename U> + bool TryStaticCast(U val, T& out) { + static_assert(std::is_arithmetic_v<U>); if constexpr (std::is_floating_point_v<T> || std::is_floating_point_v<U>) { if (val > MaxFloor<T>() || val < -MaxFloor<T>()) { - return false; - } - - } else { - if (val > Max<T>() || val < Min<T>()) { - return false; - } - } - - out = static_cast<T>(val); - return true; - } - + return false; + } + + } else { + if (val > Max<T>() || val < Min<T>()) { + return false; + } + } + + out = static_cast<T>(val); + return true; + } + /////////////////////////////////////////////////////////////////////// // THistogramBuilder /////////////////////////////////////////////////////////////////////// @@ -298,9 +298,9 @@ namespace NMonitoring { HistogramBuilder_.SetName(baseName); } - TBucketValue bucketVal; - Y_PARSER_ENSURE(TryStaticCast(value, bucketVal), "Cannot convert " << value << " to bucket value type"); - HistogramBuilder_.AddBucket(bound, bucketVal); + TBucketValue bucketVal; + Y_PARSER_ENSURE(TryStaticCast(value, bucketVal), "Cannot convert " << value << " to bucket value type"); + HistogramBuilder_.AddBucket(bound, bucketVal); HistogramBuilder_.SetTime(time); HistogramBuilder_.SetLabels(std::move(labels)); } else if (NPrometheus::IsCount(name)) { @@ -398,7 +398,7 @@ namespace NMonitoring { CurrentByte_ = Data_[CurrentPos_++]; } - Y_FORCE_INLINE bool IsSpace(char ch) { + Y_FORCE_INLINE bool IsSpace(char ch) { return ch == ' ' || ch == '\t'; } @@ -414,7 +414,7 @@ namespace NMonitoring { } void SkipSpaces() { - while (HasRemaining() && IsSpace(CurrentByte_)) { + while (HasRemaining() && IsSpace(CurrentByte_)) { ReadNextByteUnsafe(); } } @@ -428,7 +428,7 @@ namespace NMonitoring { TStringBuf ReadToken() { Y_VERIFY_DEBUG(CurrentPos_ > 0); size_t begin = CurrentPos_ - 1; // read first byte again - while (HasRemaining() && !IsSpace(CurrentByte_) && CurrentByte_ != '\n') { + while (HasRemaining() && !IsSpace(CurrentByte_) && CurrentByte_ != '\n') { ReadNextByteUnsafe(); } return TokenFromPos(begin); @@ -529,11 +529,11 @@ namespace NMonitoring { } void ConsumeCounter(TStringBuf name, const TLabelsMap& labels, TInstant time, double value) { - i64 intValue{0}; - // not nan - if (value == value) { - Y_PARSER_ENSURE(TryStaticCast(value, intValue), "value " << value << " is out of range"); - } + i64 intValue{0}; + // not nan + if (value == value) { + Y_PARSER_ENSURE(TryStaticCast(value, intValue), "value " << value << " is out of range"); + } // see https://st.yandex-team.ru/SOLOMON-4142 for more details // why we convert Prometheus COUNTER into Solomon RATE diff --git a/library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp b/library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp index db7f76978c..15efeb8c03 100644 --- a/library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp +++ b/library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp @@ -126,7 +126,7 @@ namespace NMonitoring { void WriteLabels(const TLabels& labels, TStringBuf addLabelKey, TStringBuf addLabelValue) { Out_->Write('{'); - for (auto&& l: labels) { + for (auto&& l: labels) { Out_->Write(l.Name()); Out_->Write('='); WriteLabelValue(l.Value()); @@ -354,7 +354,7 @@ namespace NMonitoring { } // XXX: poor performace - for (auto&& l: CommonLabels_) { + for (auto&& l: CommonLabels_) { MetricState_.Labels.Add(l.Name(), l.Value()); } @@ -363,7 +363,7 @@ namespace NMonitoring { "labels " << MetricState_.Labels << " does not contain label '" << MetricNameLabel_ << '\''); - const TString& metricName = ToString(nameLabel->Value()); + const TString& metricName = ToString(nameLabel->Value()); if (MetricState_.Type != EMetricType::DSUMMARY) { Writer_.WriteType(MetricState_.Type, metricName); } |