aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/encode/prometheus
diff options
context:
space:
mode:
authormsherbakov <msherbakov@yandex-team.ru>2022-02-10 16:49:16 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:16 +0300
commitc224a621661ddd69699f9476922eb316607ef57e (patch)
tree33f4d878aa0a9faa964005e06bfab0272313aa71 /library/cpp/monlib/encode/prometheus
parent29d0b2eeae154d04156e0698067c0c21a97ea61d (diff)
downloadydb-c224a621661ddd69699f9476922eb316607ef57e.tar.gz
Restoring authorship annotation for <msherbakov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/encode/prometheus')
-rw-r--r--library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp54
-rw-r--r--library/cpp/monlib/encode/prometheus/prometheus_encoder.cpp6
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 7e81357dbd..2195d9e125 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 15efeb8c03..db7f76978c 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);
}