Skip to content

Commit

Permalink
metrics: refine some metrics name (#6249)
Browse files Browse the repository at this point in the history
ref #6233
  • Loading branch information
LittleFall authored Nov 4, 2022
1 parent 0ecaf19 commit bbe3098
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions dbms/src/Common/TiFlashMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ namespace DB
/// 4. Keep it proper formatted using clang-format.
// clang-format off
#define APPLY_FOR_METRICS(M, F) \
M(tiflash_coprocessor_request_count, "Total number of request", Counter, F(type_cop, {"type", "cop"}), F(type_cop_dag, {"type", "cop_dag"}), \
F(type_super_batch, {"type", "super_batch"}), F(type_super_batch_cop_dag, {"type", "super_batch_cop_dag"}), \
M(tiflash_coprocessor_request_count, "Total number of request", Counter, F(type_cop, {"type", "cop"}), F(type_cop_executing, {"type", "cop_executing"}), \
F(type_batch, {"type", "batch"}), F(type_batch_executing, {"type", "batch_executing"}), \
F(type_dispatch_mpp_task, {"type", "dispatch_mpp_task"}), F(type_mpp_establish_conn, {"type", "mpp_establish_conn"}), \
F(type_cancel_mpp_task, {"type", "cancel_mpp_task"}), F(type_run_mpp_task, {"type", "run_mpp_task"}), \
F(type_remote_read, {"type", "remote_read"}), F(type_remote_read_sent, {"type", "remote_read_sent"})) \
M(tiflash_coprocessor_handling_request_count, "Number of handling request", Gauge, F(type_cop, {"type", "cop"}), F(type_cop_dag, {"type", "cop_dag"}), \
F(type_super_batch, {"type", "super_batch"}), F(type_super_batch_cop_dag, {"type", "super_batch_cop_dag"}), \
M(tiflash_coprocessor_handling_request_count, "Number of handling request", Gauge, F(type_cop, {"type", "cop"}), F(type_cop_executing, {"type", "cop_executing"}), \
F(type_batch, {"type", "batch"}), F(type_batch_executing, {"type", "batch_executing"}), \
F(type_dispatch_mpp_task, {"type", "dispatch_mpp_task"}), F(type_mpp_establish_conn, {"type", "mpp_establish_conn"}), \
F(type_cancel_mpp_task, {"type", "cancel_mpp_task"}), F(type_run_mpp_task, {"type", "run_mpp_task"}), \
F(type_remote_read, {"type", "remote_read"}), F(type_remote_read_dag, {"type", "remote_read_dag"})) \
F(type_remote_read, {"type", "remote_read"}), F(type_remote_read_executing, {"type", "remote_read_executing"})) \
M(tiflash_coprocessor_executor_count, "Total number of each executor", Counter, F(type_ts, {"type", "table_scan"}), \
F(type_sel, {"type", "selection"}), F(type_agg, {"type", "aggregation"}), F(type_topn, {"type", "top_n"}), \
F(type_limit, {"type", "limit"}), F(type_join, {"type", "join"}), F(type_exchange_sender, {"type", "exchange_sender"}), \
Expand All @@ -61,22 +61,22 @@ namespace DB
F(type_window, {"type", "window"}), F(type_window_sort, {"type", "window_sort"})) \
M(tiflash_coprocessor_request_duration_seconds, "Bucketed histogram of request duration", Histogram, \
F(type_cop, {{"type", "cop"}}, ExpBuckets{0.001, 2, 20}), \
F(type_super_batch, {{"type", "super_batch"}}, ExpBuckets{0.001, 2, 20}), \
F(type_batch, {{"type", "batch"}}, ExpBuckets{0.001, 2, 20}), \
F(type_dispatch_mpp_task, {{"type", "dispatch_mpp_task"}}, ExpBuckets{0.001, 2, 20}), \
F(type_mpp_establish_conn, {{"type", "mpp_establish_conn"}}, ExpBuckets{0.001, 2, 20}), \
F(type_cancel_mpp_task, {{"type", "cancel_mpp_task"}}, ExpBuckets{0.001, 2, 20}), \
F(type_run_mpp_task, {{"type", "run_mpp_task"}}, ExpBuckets{0.001, 2, 20})) \
M(tiflash_coprocessor_request_memory_usage, "Bucketed histogram of request memory usage", Histogram, \
F(type_cop, {{"type", "cop"}}, ExpBuckets{1024 * 1024, 2, 16}), \
F(type_super_batch, {{"type", "super_batch"}}, ExpBuckets{1024 * 1024, 2, 20}), \
F(type_batch, {{"type", "batch"}}, ExpBuckets{1024 * 1024, 2, 20}), \
F(type_run_mpp_task, {{"type", "run_mpp_task"}}, ExpBuckets{1024 * 1024, 2, 20})) \
M(tiflash_coprocessor_request_error, "Total number of request error", Counter, F(reason_meet_lock, {"reason", "meet_lock"}), \
F(reason_region_not_found, {"reason", "region_not_found"}), F(reason_epoch_not_match, {"reason", "epoch_not_match"}), \
F(reason_kv_client_error, {"reason", "kv_client_error"}), F(reason_internal_error, {"reason", "internal_error"}), \
F(reason_other_error, {"reason", "other_error"})) \
M(tiflash_coprocessor_request_handle_seconds, "Bucketed histogram of request handle duration", Histogram, \
F(type_cop, {{"type", "cop"}}, ExpBuckets{0.001, 2, 20}), \
F(type_super_batch, {{"type", "super_batch"}}, ExpBuckets{0.001, 2, 20}), \
F(type_batch, {{"type", "batch"}}, ExpBuckets{0.001, 2, 20}), \
F(type_dispatch_mpp_task, {{"type", "dispatch_mpp_task"}}, ExpBuckets{0.001, 2, 20}), \
F(type_mpp_establish_conn, {{"type", "mpp_establish_conn"}}, ExpBuckets{0.001, 2, 20}), \
F(type_cancel_mpp_task, {{"type", "cancel_mpp_task"}}, ExpBuckets{0.001, 2, 20}), \
Expand Down
8 changes: 4 additions & 4 deletions dbms/src/Flash/BatchCoprocessorHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ BatchCoprocessorHandler::BatchCoprocessorHandler(
grpc::Status BatchCoprocessorHandler::execute()
{
Stopwatch watch;
SCOPE_EXIT({ GET_METRIC(tiflash_coprocessor_request_handle_seconds, type_super_batch).Observe(watch.elapsedSeconds()); });
SCOPE_EXIT({ GET_METRIC(tiflash_coprocessor_request_handle_seconds, type_batch).Observe(watch.elapsedSeconds()); });

try
{
switch (cop_request->tp())
{
case COP_REQ_TYPE_DAG:
{
GET_METRIC(tiflash_coprocessor_request_count, type_super_batch_cop_dag).Increment();
GET_METRIC(tiflash_coprocessor_handling_request_count, type_super_batch_cop_dag).Increment();
GET_METRIC(tiflash_coprocessor_request_count, type_batch_executing).Increment();
GET_METRIC(tiflash_coprocessor_handling_request_count, type_batch_executing).Increment();
SCOPE_EXIT(
{ GET_METRIC(tiflash_coprocessor_handling_request_count, type_super_batch_cop_dag).Decrement(); });
{ GET_METRIC(tiflash_coprocessor_handling_request_count, type_batch_executing).Decrement(); });

auto dag_request = getDAGRequestFromStringWithRetry(cop_request->data());
auto tables_regions_info = TablesRegionsInfo::create(cop_request->regions(), cop_request->table_regions(), cop_context.db_context.getTMTContext());
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Flash/Coprocessor/DAGDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ try
}
else
{
GET_METRIC(tiflash_coprocessor_request_memory_usage, type_super_batch).Observe(peak_memory);
GET_METRIC(tiflash_coprocessor_request_memory_usage, type_batch).Observe(peak_memory);
}
}

Expand Down
6 changes: 3 additions & 3 deletions dbms/src/Flash/CoprocessorHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ grpc::Status CoprocessorHandler::execute()
{
case COP_REQ_TYPE_DAG:
{
GET_METRIC(tiflash_coprocessor_request_count, type_cop_dag).Increment();
GET_METRIC(tiflash_coprocessor_handling_request_count, type_cop_dag).Increment();
SCOPE_EXIT({ GET_METRIC(tiflash_coprocessor_handling_request_count, type_cop_dag).Decrement(); });
GET_METRIC(tiflash_coprocessor_request_count, type_cop_executing).Increment();
GET_METRIC(tiflash_coprocessor_handling_request_count, type_cop_executing).Increment();
SCOPE_EXIT({ GET_METRIC(tiflash_coprocessor_handling_request_count, type_cop_executing).Decrement(); });

tipb::DAGRequest dag_request = getDAGRequestFromStringWithRetry(cop_request->data());
LOG_DEBUG(log, "Handling DAG request: {}", dag_request.DebugString());
Expand Down
12 changes: 6 additions & 6 deletions dbms/src/Flash/FlashService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ grpc::Status FlashService::Coprocessor(
return status;
}
if (is_remote_read)
GET_METRIC(tiflash_coprocessor_handling_request_count, type_remote_read_dag).Increment();
GET_METRIC(tiflash_coprocessor_handling_request_count, type_remote_read_executing).Increment();
SCOPE_EXIT({
if (is_remote_read)
GET_METRIC(tiflash_coprocessor_handling_request_count, type_remote_read_dag).Decrement();
GET_METRIC(tiflash_coprocessor_handling_request_count, type_remote_read_executing).Decrement();
});
CoprocessorContext cop_context(*db_context, request->context(), *grpc_context);
CoprocessorHandler cop_handler(cop_context, request, response);
Expand All @@ -167,12 +167,12 @@ grpc::Status FlashService::BatchCoprocessor(grpc::ServerContext * grpc_context,
if (!check_result.ok())
return check_result;

GET_METRIC(tiflash_coprocessor_request_count, type_super_batch).Increment();
GET_METRIC(tiflash_coprocessor_handling_request_count, type_super_batch).Increment();
GET_METRIC(tiflash_coprocessor_request_count, type_batch).Increment();
GET_METRIC(tiflash_coprocessor_handling_request_count, type_batch).Increment();
Stopwatch watch;
SCOPE_EXIT({
GET_METRIC(tiflash_coprocessor_handling_request_count, type_super_batch).Decrement();
GET_METRIC(tiflash_coprocessor_request_duration_seconds, type_super_batch).Observe(watch.elapsedSeconds());
GET_METRIC(tiflash_coprocessor_handling_request_count, type_batch).Decrement();
GET_METRIC(tiflash_coprocessor_request_duration_seconds, type_batch).Observe(watch.elapsedSeconds());
// TODO: update the value of metric tiflash_coprocessor_response_bytes.
});

Expand Down

0 comments on commit bbe3098

Please sign in to comment.