row_cache: cache_tracker: Do not register metrics when constructed for tests
Some tests will create two cache_tracker instances because of one being embedded in the sstable test env. This would lead to double registration of metrics, which raises run time error. Avoid by not registering metrics in prometheus in tests at all.
This commit is contained in:
@@ -93,7 +93,8 @@ private:
|
||||
private:
|
||||
void setup_metrics();
|
||||
public:
|
||||
cache_tracker(mutation_application_stats&);
|
||||
using register_metrics = bool_class<class register_metrics_tag>;
|
||||
cache_tracker(mutation_application_stats&, register_metrics = register_metrics::yes);
|
||||
cache_tracker();
|
||||
~cache_tracker();
|
||||
void clear();
|
||||
|
||||
@@ -53,16 +53,18 @@ row_cache::create_underlying_reader(read_context& ctx, mutation_source& src, con
|
||||
static thread_local mutation_application_stats dummy_app_stats;
|
||||
|
||||
cache_tracker::cache_tracker()
|
||||
: cache_tracker(dummy_app_stats)
|
||||
: cache_tracker(dummy_app_stats, register_metrics::no)
|
||||
{}
|
||||
|
||||
static thread_local cache_tracker* current_tracker;
|
||||
|
||||
cache_tracker::cache_tracker(mutation_application_stats& app_stats)
|
||||
cache_tracker::cache_tracker(mutation_application_stats& app_stats, register_metrics with_metrics)
|
||||
: _garbage(_region, this, app_stats)
|
||||
, _memtable_cleaner(_region, nullptr, app_stats)
|
||||
{
|
||||
setup_metrics();
|
||||
if (with_metrics) {
|
||||
setup_metrics();
|
||||
}
|
||||
|
||||
_region.make_evictable([this] {
|
||||
return with_allocator(_region.allocator(), [this] {
|
||||
|
||||
Reference in New Issue
Block a user