[Metrics] Support tablet level metrics (#4428)

Sometimes we want to detect the hotspot of a cluster, for example, hot scanned tablet, hot wrote tablet,
but we have no insight about tablets in the cluster.
This patch introduce tablet level metrics to help to achieve this object, now support 4 metrics on tablets: `query_scan_bytes `, `query_scan_rows `, `flush_bytes `, `flush_count `. 
However, one BE may holds hundreds of thousands of tablets, so I add a parameter for the metrics HTTP request,
and not return tablet level metrics by default.
This commit is contained in:
Yingchun Lai
2020-09-02 10:39:41 +08:00
committed by GitHub
parent f3a9f3f87c
commit 498b06fbe2
51 changed files with 729 additions and 615 deletions

View File

@ -71,7 +71,7 @@ Status ClientCacheHelper::get_client(
_client_map[*client_key]->set_recv_timeout(timeout_ms);
if (_metrics_enabled) {
thrift_used_clients.increment(1);
thrift_used_clients->increment(1);
}
return Status::OK();
@ -96,7 +96,7 @@ Status ClientCacheHelper::reopen_client(client_factory factory_method, void** cl
*client_key = NULL;
if (_metrics_enabled) {
thrift_opened_clients.increment(-1);
thrift_opened_clients->increment(-1);
}
RETURN_IF_ERROR(create_client(make_network_address(
@ -127,7 +127,7 @@ Status ClientCacheHelper::create_client(
_client_map[*client_key] = client_impl.release();
if (_metrics_enabled) {
thrift_opened_clients.increment(1);
thrift_opened_clients->increment(1);
}
return Status::OK();
@ -149,14 +149,14 @@ void ClientCacheHelper::release_client(void** client_key) {
delete info;
if (_metrics_enabled) {
thrift_opened_clients.increment(-1);
thrift_opened_clients->increment(-1);
}
} else {
j->second.push_back(*client_key);
}
if (_metrics_enabled) {
thrift_used_clients.increment(-1);
thrift_used_clients->increment(-1);
}
*client_key = NULL;
@ -222,8 +222,8 @@ void ClientCacheHelper::init_metrics(const std::string& name) {
_thrift_client_metric_entity =
DorisMetrics::instance()->metric_registry()->register_entity(
std::string("thrift_client.") + name, {{"name", name}});
METRIC_REGISTER(_thrift_client_metric_entity, thrift_used_clients);
METRIC_REGISTER(_thrift_client_metric_entity, thrift_opened_clients);
INT_GAUGE_METRIC_REGISTER(_thrift_client_metric_entity, thrift_used_clients);
INT_GAUGE_METRIC_REGISTER(_thrift_client_metric_entity, thrift_opened_clients);
_metrics_enabled = true;
}