aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-10 11:11:27 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 15:58:17 +0300
commit4ea9ba77900523cdb8765a260b28d0a7ef906806 (patch)
tree28970f6ff02ab18cb5bc5044b9afbde70db95f6b /library
parentd80d342ddc1aff6e89a7fc1183ea621bc7ed4387 (diff)
downloadydb-4ea9ba77900523cdb8765a260b28d0a7ef906806.tar.gz
intermediate changes
ref:2c3e46cc24129798623a4e38cf6e79cae4c95dac
Diffstat (limited to 'library')
-rw-r--r--library/cpp/charset/ci_string.cpp1
-rw-r--r--library/cpp/charset/cp_encrec.cpp1
-rw-r--r--library/cpp/charset/generated/encrec_data.cpp2
-rw-r--r--library/cpp/monlib/metrics/metric_registry.cpp5
-rw-r--r--library/cpp/monlib/metrics/metric_registry.h7
-rw-r--r--library/cpp/monlib/metrics/metric_registry_ut.cpp17
6 files changed, 29 insertions, 4 deletions
diff --git a/library/cpp/charset/ci_string.cpp b/library/cpp/charset/ci_string.cpp
index 634b05ec68..6097e40131 100644
--- a/library/cpp/charset/ci_string.cpp
+++ b/library/cpp/charset/ci_string.cpp
@@ -1,5 +1,4 @@
#include "ci_string.h"
-#include "wide.h"
int TCiString::compare(const TCiString& s1, const TCiString& s2, const CodePage& cp) {
return cp.stricmp(s1.data(), s2.data());
diff --git a/library/cpp/charset/cp_encrec.cpp b/library/cpp/charset/cp_encrec.cpp
index 1334afaa90..e4570cd628 100644
--- a/library/cpp/charset/cp_encrec.cpp
+++ b/library/cpp/charset/cp_encrec.cpp
@@ -1,6 +1,5 @@
#include "codepage.h"
-#include <util/string/cast.h>
#include <util/stream/output.h>
void Encoder::Tr(const wchar32* in, char* out, size_t len) const {
diff --git a/library/cpp/charset/generated/encrec_data.cpp b/library/cpp/charset/generated/encrec_data.cpp
index c1a8579dac..ca59f8ddef 100644
--- a/library/cpp/charset/generated/encrec_data.cpp
+++ b/library/cpp/charset/generated/encrec_data.cpp
@@ -1,5 +1,4 @@
#include <library/cpp/charset/codepage.h>
-#include <library/cpp/charset/wide.h>
extern const char defchars[][DEFCHAR_BUF];
static const char PP_00[257] =
@@ -15079,4 +15078,3 @@ const Recoder NCodepagePrivate::TCodePageData::rcdr_to_title[] = {
{{},},
{{},},
};
-
diff --git a/library/cpp/monlib/metrics/metric_registry.cpp b/library/cpp/monlib/metrics/metric_registry.cpp
index e46141ccde..b083163a7b 100644
--- a/library/cpp/monlib/metrics/metric_registry.cpp
+++ b/library/cpp/monlib/metrics/metric_registry.cpp
@@ -152,6 +152,11 @@ namespace NMonitoring {
}
}
+ void TMetricRegistry::Clear() {
+ TWriteGuard g{Lock_};
+ Metrics_.clear();
+ }
+
template <typename TMetric, EMetricType type, typename TLabelsType, typename... Args>
TMetric* TMetricRegistry::Metric(TLabelsType&& labels, Args&&... args) {
{
diff --git a/library/cpp/monlib/metrics/metric_registry.h b/library/cpp/monlib/metrics/metric_registry.h
index 68b2d652cb..670cf8651e 100644
--- a/library/cpp/monlib/metrics/metric_registry.h
+++ b/library/cpp/monlib/metrics/metric_registry.h
@@ -79,7 +79,14 @@ namespace NMonitoring {
TLabels labels,
IHistogramCollectorPtr collector);
+ /**
+ * Set all registered metrics to zero
+ */
void Reset();
+ /**
+ * Remove all registered metrics from registry
+ */
+ void Clear();
void Accept(TInstant time, IMetricConsumer* consumer) const override;
void Append(TInstant time, IMetricConsumer* consumer) const override;
diff --git a/library/cpp/monlib/metrics/metric_registry_ut.cpp b/library/cpp/monlib/metrics/metric_registry_ut.cpp
index afcbcd6801..86d9a52ec0 100644
--- a/library/cpp/monlib/metrics/metric_registry_ut.cpp
+++ b/library/cpp/monlib/metrics/metric_registry_ut.cpp
@@ -299,4 +299,21 @@ Y_UNIT_TEST_SUITE(TMetricRegistryTest) {
"\"sensors\":[{\"kind\":\"GAUGE\",\"labels\":{\"my\":\"gauge\"},\"value\":12.34}]}");
}
}
+
+ Y_UNIT_TEST(MetricsRegistryClear) {
+ TMetricRegistry registry;
+ registry.Gauge({{"some", "label"}})->Add(1);
+
+ NProto::TSingleSamplesList samples;
+ auto encoder = EncoderProtobuf(&samples);
+ registry.Accept(TInstant::Now(), encoder.Get());
+
+ UNIT_ASSERT(samples.SamplesSize() == 1);
+
+ samples = {};
+ registry.Clear();
+ registry.Accept(TInstant::Now(), encoder.Get());
+
+ UNIT_ASSERT(samples.SamplesSize() == 0);
+ }
}