Skip to content

Commit

Permalink
[BE] Add scanner/etl thread pool queue size metric. (apache#5619)
Browse files Browse the repository at this point in the history
* [BE] Add scanner/etl thread pool queue size metric.

* Fix compilation problem.
  • Loading branch information
killxdcj authored Apr 20, 2021
1 parent 7445051 commit a2e83e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions be/src/runtime/exec_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class ExecEnv {
/// Initialise 'buffer_pool_' and 'buffer_reservation_' with given capacity.
void _init_buffer_pool(int64_t min_page_len, int64_t capacity, int64_t clean_pages_limit);

void _register_metrics();
void _deregister_metrics();

private:
bool _is_init;
std::vector<StorePath> _store_paths;
Expand Down
20 changes: 20 additions & 0 deletions be/src/runtime/exec_env_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@

namespace doris {

DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(scanner_thread_pool_queue_size, MetricUnit::NOUNIT);
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(etl_thread_pool_queue_size, MetricUnit::NOUNIT);

Status ExecEnv::init(ExecEnv* env, const std::vector<StorePath>& store_paths) {
return env->_init(store_paths);
}
Expand Down Expand Up @@ -125,6 +128,7 @@ Status ExecEnv::_init(const std::vector<StorePath>& store_paths) {

RETURN_IF_ERROR(_load_channel_mgr->init(_mem_tracker->limit()));
_heartbeat_flags = new HeartbeatFlags();
_register_metrics();
_is_init = true;
return Status::OK();
}
Expand Down Expand Up @@ -208,11 +212,27 @@ void ExecEnv::_init_buffer_pool(int64_t min_page_size, int64_t capacity,
_buffer_reservation->InitRootTracker(nullptr, capacity);
}

void ExecEnv::_register_metrics() {
REGISTER_HOOK_METRIC(scanner_thread_pool_queue_size, [this]() {
return _thread_pool->get_queue_size();
});

REGISTER_HOOK_METRIC(etl_thread_pool_queue_size, [this]() {
return _etl_thread_pool->get_queue_size();
});
}

void ExecEnv::_deregister_metrics() {
DEREGISTER_HOOK_METRIC(scanner_thread_pool_queue_size);
DEREGISTER_HOOK_METRIC(etl_thread_pool_queue_size);
}

void ExecEnv::_destroy() {
//Only destroy once after init
if (!_is_init) {
return;
}
_deregister_metrics();
SAFE_DELETE(_brpc_stub_cache);
SAFE_DELETE(_load_stream_mgr);
SAFE_DELETE(_load_channel_mgr);
Expand Down
3 changes: 3 additions & 0 deletions be/src/util/doris_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ class DorisMetrics {
UIntGauge* query_cache_sql_total_count;
UIntGauge* query_cache_partition_total_count;

UIntGauge* scanner_thread_pool_queue_size;
UIntGauge* etl_thread_pool_queue_size;

static DorisMetrics* instance() {
static DorisMetrics instance;
return &instance;
Expand Down

0 comments on commit a2e83e6

Please sign in to comment.