From 1b3312c7661899b9f6fdda27b71d89a6b44d26f4 Mon Sep 17 00:00:00 2001 From: yiguolei Date: Fri, 27 Dec 2024 13:55:25 +0800 Subject: [PATCH] f --- be/src/runtime/exec_env.h | 2 ++ be/src/runtime/exec_env_init.cpp | 4 ++++ be/src/util/doris_metrics.h | 5 +---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/be/src/runtime/exec_env.h b/be/src/runtime/exec_env.h index e29ab97593c5e5d..da8aa476c89a53c 100644 --- a/be/src/runtime/exec_env.h +++ b/be/src/runtime/exec_env.h @@ -114,6 +114,7 @@ class ProcessProfile; class HeapProfiler; class WalManager; class DNSCache; +class DorisMetrics; inline bool k_doris_exit = false; @@ -233,6 +234,7 @@ class ExecEnv { LoadPathMgr* load_path_mgr() { return _load_path_mgr; } BfdParser* bfd_parser() const { return _bfd_parser; } BrokerMgr* broker_mgr() const { return _broker_mgr; } + DorisMetrics* doris_metrics() { return _doris_metrics; } BrpcClientCache* brpc_internal_client_cache() const { return _internal_client_cache; } diff --git a/be/src/runtime/exec_env_init.cpp b/be/src/runtime/exec_env_init.cpp index aae3ecba048cf1e..5a45f133f14babf 100644 --- a/be/src/runtime/exec_env_init.cpp +++ b/be/src/runtime/exec_env_init.cpp @@ -204,6 +204,9 @@ Status ExecEnv::_init(const std::vector& store_paths, if (ready()) { return Status::OK(); } + // Doris Metrics is firstly initialized. + _doris_metrics = std::make_unique(); + std::unordered_map> spill_store_map; for (const auto& spill_path : spill_store_paths) { spill_store_map.emplace(spill_path.path, std::make_unique( @@ -842,6 +845,7 @@ void ExecEnv::destroy() { SAFE_DELETE(_heap_profiler); _s_tracking_memory = false; + _doris_metrics.reset(); LOG(INFO) << "Doris exec envorinment is destoried."; } diff --git a/be/src/util/doris_metrics.h b/be/src/util/doris_metrics.h index d089758c21c93fc..9175785aaa61423 100644 --- a/be/src/util/doris_metrics.h +++ b/be/src/util/doris_metrics.h @@ -248,10 +248,7 @@ class DorisMetrics { IntCounter* scanner_task_submit_failed = nullptr; IntCounter* scanner_task_running = nullptr; - static DorisMetrics* instance() { - static DorisMetrics instance; - return &instance; - } + static DorisMetrics* instance() { return ExecEnv::GetInstance()->doris_metrics(); } // not thread-safe, call before calling metrics void initialize(