aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/metrics/metric_registry_ut.cpp
diff options
context:
space:
mode:
authormiktorius <miktorius@yandex-team.com>2025-03-03 12:16:59 +0300
committermiktorius <miktorius@yandex-team.com>2025-03-03 12:35:24 +0300
commite5e00e2a402f3028369f177f5919182949a71ba6 (patch)
treed06a7353708c3ed2fdf2db2a20eab8e7c6f24746 /library/cpp/monlib/metrics/metric_registry_ut.cpp
parent5fc9035f13cbbee5e75a9f7933bb877454a40c24 (diff)
downloadydb-e5e00e2a402f3028369f177f5919182949a71ba6.tar.gz
monlib : adding memOnly flag support for cpp lib
commit_hash:cffc55ecd6d0ea22c3c2ce52f21e6aba6da16a15
Diffstat (limited to 'library/cpp/monlib/metrics/metric_registry_ut.cpp')
-rw-r--r--library/cpp/monlib/metrics/metric_registry_ut.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/library/cpp/monlib/metrics/metric_registry_ut.cpp b/library/cpp/monlib/metrics/metric_registry_ut.cpp
index 802c423264..89e6d56146 100644
--- a/library/cpp/monlib/metrics/metric_registry_ut.cpp
+++ b/library/cpp/monlib/metrics/metric_registry_ut.cpp
@@ -396,4 +396,76 @@ Y_UNIT_TEST_SUITE(TMetricRegistryTest) {
UNIT_ASSERT(commonLabels[0].GetName() == "common");
UNIT_ASSERT(commonLabels[0].GetValue() == "label");
}
+
+ Y_UNIT_TEST(MemOnlyMetric) {
+ TMetricRegistry registry;
+ i64 int_val = 0;
+ double double_val = 0;
+
+ registry.GaugeWithOpts({{"some", "gauge"}}, {true});
+ UNIT_ASSERT_EXCEPTION(registry.Gauge({{"some", "gauge"}}), yexception);
+
+ registry.LazyGaugeWithOpts(
+ {{"some", "lazy_gauge"}},
+ [&double_val](){return double_val;},
+ {true});
+ UNIT_ASSERT_EXCEPTION(
+ registry.LazyGauge(
+ {{"some", "lazy_gauge"}},
+ [&double_val](){return double_val;}),
+ yexception);
+
+ registry.IntGaugeWithOpts({{"some", "int_gauge"}}, {true});
+ UNIT_ASSERT_EXCEPTION(registry.IntGauge({{"some", "int_gauge"}}), yexception);
+
+ registry.LazyIntGaugeWithOpts(
+ {{"some", "lazy_int_gauge"}},
+ [&int_val](){return int_val;},
+ {true});
+ UNIT_ASSERT_EXCEPTION(
+ registry.LazyIntGauge(
+ {{"some", "lazy_int_gauge"}},
+ [&int_val](){return int_val;}),
+ yexception);
+
+ registry.CounterWithOpts({{"some", "counter"}}, {true});
+ UNIT_ASSERT_EXCEPTION(registry.Counter({{"some", "counter"}}), yexception);
+
+ registry.LazyCounterWithOpts({{"some", "lazy_counter"}}, [&int_val](){return int_val;}, {true});
+ UNIT_ASSERT_EXCEPTION(
+ registry.LazyCounter(
+ {{"some", "lazy_counter"}},
+ [&int_val](){return int_val;}),
+ yexception);
+
+ registry.RateWithOpts({{"some", "rate"}}, {true});
+ UNIT_ASSERT_EXCEPTION(registry.Rate({{"some", "rate"}}), yexception);
+
+ registry.LazyRateWithOpts({{"some", "lazy_rate"}}, [&double_val](){return double_val;}, {true});
+ UNIT_ASSERT_EXCEPTION(
+ registry.LazyRate(
+ {{"some", "lazy_rate"}},
+ [&double_val](){return double_val;}),
+ yexception);
+
+ registry.HistogramCounterWithOpts(
+ {{"some", "histogram_counter"}},
+ ExplicitHistogram({1, 5, 15, 20, 25}),
+ {true});
+ UNIT_ASSERT_EXCEPTION(
+ registry.HistogramCounter(
+ {{"some", "histogram_counter"}},
+ ExplicitHistogram({1, 5, 15, 20, 25})),
+ yexception);
+
+ registry.HistogramRateWithOpts(
+ {{"some", "histogram_rate"}},
+ ExponentialHistogram(5, 2),
+ {true});
+ UNIT_ASSERT_EXCEPTION(
+ registry.HistogramRate(
+ {{"some", "histogram_rate"}},
+ ExponentialHistogram(5, 2)),
+ yexception);
+ }
}