yiguolei commented on code in PR #43144: URL: https://github.com/apache/doris/pull/43144#discussion_r1895228362
########## be/src/util/threadpool.cpp: ########## @@ -269,10 +286,35 @@ Status ThreadPool::init() { return status; } } + + _metric_entity = DorisMetrics::instance()->metric_registry()->register_entity( + fmt::format("thread_pool_{}", _name), + {{"thread_pool_name", _name}, {"workload_group", _workload_group}}); + + INT_GAUGE_METRIC_REGISTER(_metric_entity, thread_pool_active_threads); + INT_GAUGE_METRIC_REGISTER(_metric_entity, thread_pool_max_threads); + INT_GAUGE_METRIC_REGISTER(_metric_entity, thread_pool_queue_size); + INT_GAUGE_METRIC_REGISTER(_metric_entity, thread_pool_max_queue_size); + INT_GAUGE_METRIC_REGISTER(_metric_entity, task_execution_time_ns_avg_in_last_1000_times); + INT_GAUGE_METRIC_REGISTER(_metric_entity, task_wait_worker_ns_avg_in_last_1000_times); + INT_ATOMIC_COUNTER_METRIC_REGISTER(_metric_entity, thread_pool_submit_failed); + + _metric_entity->register_hook("update", [this]() { + thread_pool_active_threads->set_value(num_active_threads()); + thread_pool_queue_size->set_value(get_queue_size()); + thread_pool_max_queue_size->set_value(get_max_queue_size()); + thread_pool_max_threads->set_value(max_threads()); + task_execution_time_ns_avg_in_last_1000_times->set_value( + _task_execution_time_ns_statistic.mean()); + task_wait_worker_ns_avg_in_last_1000_times->set_value( + _task_wait_worker_time_ns_statistic.mean()); + }); + return Status::OK(); } void ThreadPool::shutdown() { + DorisMetrics::instance()->metric_registry()->deregister_entity(_metric_entity); Review Comment: 如果先deregister,假如此时还有task run,这个task run 结束之后,更新metric 会不会导致内存写脏? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org