aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/metrics/labels.cpp
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/metrics/labels.cpp
parent29d0b2eeae154d04156e0698067c0c21a97ea61d (diff)
downloadydb-c224a621661ddd69699f9476922eb316607ef57e.tar.gz
Restoring authorship annotation for <msherbakov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/metrics/labels.cpp')
-rw-r--r--library/cpp/monlib/metrics/labels.cpp124
1 files changed, 62 insertions, 62 deletions
diff --git a/library/cpp/monlib/metrics/labels.cpp b/library/cpp/monlib/metrics/labels.cpp
index 1eaadb7cba..4dc27a11fc 100644
--- a/library/cpp/monlib/metrics/labels.cpp
+++ b/library/cpp/monlib/metrics/labels.cpp
@@ -1,21 +1,21 @@
#include "labels.h"
-#include <util/stream/output.h>
-#include <util/string/split.h>
+#include <util/stream/output.h>
+#include <util/string/split.h>
static void OutputLabels(IOutputStream& out, const NMonitoring::ILabels& labels) {
size_t i = 0;
- out << '{';
+ out << '{';
for (const auto& label: labels) {
if (i++ > 0) {
out << TStringBuf(", ");
- }
+ }
out << label;
}
- out << '}';
-}
-
-template <>
+ out << '}';
+}
+
+template <>
void Out<NMonitoring::ILabelsPtr>(IOutputStream& out, const NMonitoring::ILabelsPtr& labels) {
OutputLabels(out, *labels);
}
@@ -26,57 +26,57 @@ void Out<NMonitoring::ILabels>(IOutputStream& out, const NMonitoring::ILabels& l
}
template <>
-void Out<NMonitoring::ILabel>(IOutputStream& out, const NMonitoring::ILabel& labels) {
- out << labels.Name() << "=" << labels.Value();
-}
-
-Y_MONLIB_DEFINE_LABELS_OUT(NMonitoring::TLabels);
-Y_MONLIB_DEFINE_LABEL_OUT(NMonitoring::TLabel);
-
-namespace NMonitoring {
- bool TryLoadLabelsFromString(TStringBuf sb, ILabels& labels) {
- if (sb.Empty()) {
- return false;
- }
-
- if (!sb.StartsWith('{') || !sb.EndsWith('}')) {
- return false;
- }
-
- sb.Skip(1);
- sb.Chop(1);
-
- if (sb.Empty()) {
- return true;
- }
-
- bool ok = true;
- TVector<std::pair<TStringBuf, TStringBuf>> rawLabels;
- StringSplitter(sb).SplitBySet(" ,").SkipEmpty().Consume([&] (TStringBuf label) {
- TStringBuf key, value;
- ok &= label.TrySplit('=', key, value);
-
- if (!ok) {
- return;
- }
-
- rawLabels.emplace_back(key, value);
- });
-
- if (!ok) {
- return false;
- }
-
- for (auto&& [k, v] : rawLabels) {
- labels.Add(k, v);
- }
-
- return true;
- }
-
- bool TryLoadLabelsFromString(IInputStream& is, ILabels& labels) {
- TString str = is.ReadAll();
- return TryLoadLabelsFromString(str, labels);
- }
-
-} // namespace NMonitoring
+void Out<NMonitoring::ILabel>(IOutputStream& out, const NMonitoring::ILabel& labels) {
+ out << labels.Name() << "=" << labels.Value();
+}
+
+Y_MONLIB_DEFINE_LABELS_OUT(NMonitoring::TLabels);
+Y_MONLIB_DEFINE_LABEL_OUT(NMonitoring::TLabel);
+
+namespace NMonitoring {
+ bool TryLoadLabelsFromString(TStringBuf sb, ILabels& labels) {
+ if (sb.Empty()) {
+ return false;
+ }
+
+ if (!sb.StartsWith('{') || !sb.EndsWith('}')) {
+ return false;
+ }
+
+ sb.Skip(1);
+ sb.Chop(1);
+
+ if (sb.Empty()) {
+ return true;
+ }
+
+ bool ok = true;
+ TVector<std::pair<TStringBuf, TStringBuf>> rawLabels;
+ StringSplitter(sb).SplitBySet(" ,").SkipEmpty().Consume([&] (TStringBuf label) {
+ TStringBuf key, value;
+ ok &= label.TrySplit('=', key, value);
+
+ if (!ok) {
+ return;
+ }
+
+ rawLabels.emplace_back(key, value);
+ });
+
+ if (!ok) {
+ return false;
+ }
+
+ for (auto&& [k, v] : rawLabels) {
+ labels.Add(k, v);
+ }
+
+ return true;
+ }
+
+ bool TryLoadLabelsFromString(IInputStream& is, ILabels& labels) {
+ TString str = is.ReadAll();
+ return TryLoadLabelsFromString(str, labels);
+ }
+
+} // namespace NMonitoring