diff options
author | gusev-p <gusev-p@yandex-team.ru> | 2022-02-10 16:47:20 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:20 +0300 |
commit | 47af3b5bf148ddab250833ec454d30d7c4930c31 (patch) | |
tree | 9814fbd1c3effac9b8377c5d604b367b14e2db55 /library/cpp/monlib/encode/buffered | |
parent | 1715700d00b30399d3648be821fd585ae552365e (diff) | |
download | ydb-47af3b5bf148ddab250833ec454d30d7c4930c31.tar.gz |
Restoring authorship annotation for <gusev-p@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/encode/buffered')
3 files changed, 36 insertions, 36 deletions
diff --git a/library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp b/library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp index 4928fdf70f..87c832d642 100644 --- a/library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp +++ b/library/cpp/monlib/encode/buffered/buffered_encoder_base.cpp @@ -1,8 +1,8 @@ #include "buffered_encoder_base.h" -#include <util/string/join.h> -#include <util/string/builder.h> - +#include <util/string/join.h> +#include <util/string/builder.h> + namespace NMonitoring { void TBufferedEncoderBase::OnStreamBegin() { @@ -42,8 +42,8 @@ void TBufferedEncoderBase::OnMetricEnd() { Y_ENSURE(existing.GetValueType() == metric.TimeSeries.GetValueType(), "Time series point type mismatch: expected " << existing.GetValueType() - << " but found " << metric.TimeSeries.GetValueType() - << ", labels '" << FormatLabels(metric.Labels) << "'"); + << " but found " << metric.TimeSeries.GetValueType() + << ", labels '" << FormatLabels(metric.Labels) << "'"); existing.CopyFrom(metric.TimeSeries); Metrics_.pop_back(); @@ -144,27 +144,27 @@ void TBufferedEncoderBase::OnLogHistogram(TInstant time, TLogHistogramSnapshotPt metric.TimeSeries.Add(time, s.Get()); } -TString TBufferedEncoderBase::FormatLabels(const TPooledLabels& labels) const { - auto formattedLabels = TVector<TString>(Reserve(labels.size() + CommonLabels_.size())); - auto addLabel = [&](const TPooledLabel& l) { - auto formattedLabel = TStringBuilder() << LabelNamesPool_.Get(l.Key) << '=' << LabelValuesPool_.Get(l.Value); - formattedLabels.push_back(std::move(formattedLabel)); - }; - - for (const auto& l: labels) { - addLabel(l); - } - for (const auto& l: CommonLabels_) { - const auto it = FindIf(labels, [&](const TPooledLabel& label) { - return label.Key == l.Key; - }); - if (it == labels.end()) { - addLabel(l); - } - } - Sort(formattedLabels); - - return TStringBuilder() << "{" << JoinSeq(", ", formattedLabels) << "}"; -} - +TString TBufferedEncoderBase::FormatLabels(const TPooledLabels& labels) const { + auto formattedLabels = TVector<TString>(Reserve(labels.size() + CommonLabels_.size())); + auto addLabel = [&](const TPooledLabel& l) { + auto formattedLabel = TStringBuilder() << LabelNamesPool_.Get(l.Key) << '=' << LabelValuesPool_.Get(l.Value); + formattedLabels.push_back(std::move(formattedLabel)); + }; + + for (const auto& l: labels) { + addLabel(l); + } + for (const auto& l: CommonLabels_) { + const auto it = FindIf(labels, [&](const TPooledLabel& label) { + return label.Key == l.Key; + }); + if (it == labels.end()) { + addLabel(l); + } + } + Sort(formattedLabels); + + return TStringBuilder() << "{" << JoinSeq(", ", formattedLabels) << "}"; +} + } // namespace NMonitoring diff --git a/library/cpp/monlib/encode/buffered/buffered_encoder_base.h b/library/cpp/monlib/encode/buffered/buffered_encoder_base.h index 12f838d905..fe3714e58f 100644 --- a/library/cpp/monlib/encode/buffered/buffered_encoder_base.h +++ b/library/cpp/monlib/encode/buffered/buffered_encoder_base.h @@ -82,10 +82,10 @@ protected: TMetricTimeSeries TimeSeries; }; -protected: - TString FormatLabels(const TPooledLabels& labels) const; - -protected: +protected: + TString FormatLabels(const TPooledLabels& labels) const; + +protected: TEncoderState State_; TStringPoolBuilder LabelNamesPool_; diff --git a/library/cpp/monlib/encode/buffered/string_pool.h b/library/cpp/monlib/encode/buffered/string_pool.h index f07d050729..00e5644608 100644 --- a/library/cpp/monlib/encode/buffered/string_pool.h +++ b/library/cpp/monlib/encode/buffered/string_pool.h @@ -37,10 +37,10 @@ namespace NMonitoring { return StrVector_.at(index).first; } - TStringBuf Get(const TValue* value) const { - return StrVector_.at(value->Index).first; - } - + TStringBuf Get(const TValue* value) const { + return StrVector_.at(value->Index).first; + } + template <typename TConsumer> void ForEach(TConsumer&& c) { Y_ENSURE(IsBuilt_, "Pool must be sorted first"); |