diff options
author | Alexander Smirnov <alex@ydb.tech> | 2025-03-04 13:29:55 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2025-03-04 13:29:55 +0000 |
commit | d96ec0e9abafbb5a2f9cd92fa3551bb669975a45 (patch) | |
tree | f9759f0ce79cbf8cfef05f17bac4444b68d6673d /library/cpp/monlib/metrics/metric_registry_ut.cpp | |
parent | ad0b83372abbcedc2887412cfdd967ea22b7148e (diff) | |
parent | 0ae3f82349eeb4f353c62dd726e4ba06bbc837f9 (diff) | |
download | ydb-d96ec0e9abafbb5a2f9cd92fa3551bb669975a45.tar.gz |
Merge branch 'rightlib' into merge-libs-250304-1328
Diffstat (limited to 'library/cpp/monlib/metrics/metric_registry_ut.cpp')
-rw-r--r-- | library/cpp/monlib/metrics/metric_registry_ut.cpp | 72 |
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 802c423264c..89e6d56146f 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); + } } |