Coverage Report

Created: 2026-07-17 19:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/common/metrics/doris_metrics.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <jni.h>
21
22
#include <memory>
23
#include <set>
24
#include <string>
25
#include <vector>
26
27
#include "common/metrics/jvm_metrics.h"
28
#include "common/metrics/metrics.h"
29
#include "common/metrics/system_metrics.h"
30
31
namespace doris {
32
33
#define REGISTER_ENTITY_HOOK_METRIC(entity, owner, metric, func)                        \
34
754
    owner->metric = (UIntGauge*)(entity->register_metric<UIntGauge>(&METRIC_##metric)); \
35
30.1k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
storage_engine.cpp:_ZZN5doris13StorageEngineC1ERKNS_13EngineOptionsEENK3$_0clEv
Line
Count
Source
35
698
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
broker_mgr.cpp:_ZZN5doris9BrokerMgrC1EPNS_7ExecEnvEENK3$_0clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
external_scan_context_mgr.cpp:_ZZN5doris22ExternalScanContextMgrC1EPNS_7ExecEnvEENK3$_0clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
result_buffer_mgr.cpp:_ZZN5doris15ResultBufferMgrC1EvENK3$_0clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
result_queue_mgr.cpp:_ZZN5doris14ResultQueueMgrC1EvENK3$_0clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
small_file_mgr.cpp:_ZZN5doris12SmallFileMgrC1EPNS_7ExecEnvERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEENK3$_0clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_0clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_1clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_2clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_3clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_4clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_5clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_6clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_7clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_8clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_9clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK4$_10clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK4$_11clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK4$_12clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK4$_13clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK4$_14clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK4$_15clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
brpc_client_cache.cpp:_ZZN5doris15BrpcClientCacheINS_20PBackendService_StubEEC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_S8_ENK3$_0clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
brpc_client_cache.cpp:_ZZN5doris15BrpcClientCacheINS_20PBackendService_StubEEC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_S8_ENK3$_1clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
brpc_client_cache.cpp:_ZZN5doris15BrpcClientCacheINS_21PFunctionService_StubEEC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_S8_ENK3$_0clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
load_channel_mgr.cpp:_ZZN5doris14LoadChannelMgrC1EvENK3$_0clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
tablets_channel.cpp:_ZZZN5doris18BaseTabletsChannelC1ERKNS_17TabletsChannelKeyERKNS_8UniqueIdEbPNS_14RuntimeProfileEENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
959
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
memtable_memory_limiter.cpp:_ZZN5doris21MemTableMemoryLimiter4initElENK3$_0clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
routine_load_task_executor.cpp:_ZZN5doris23RoutineLoadTaskExecutorC1EPNS_7ExecEnvEENK3$_0clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
new_load_stream_mgr.cpp:_ZZN5doris16NewLoadStreamMgrC1EvENK3$_0clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
storage_engine.cpp:_ZZZN5doris13StorageEngineC1ERKNS_13EngineOptionsEENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
698
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
broker_mgr.cpp:_ZZZN5doris9BrokerMgrC1EPNS_7ExecEnvEENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
external_scan_context_mgr.cpp:_ZZZN5doris22ExternalScanContextMgrC1EPNS_7ExecEnvEENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
result_buffer_mgr.cpp:_ZZZN5doris15ResultBufferMgrC1EvENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
result_queue_mgr.cpp:_ZZZN5doris14ResultQueueMgrC1EvENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
small_file_mgr.cpp:_ZZZN5doris12SmallFileMgrC1EPNS_7ExecEnvERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_1clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_2clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_3clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_4clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_5clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_6clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_7clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_8clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK3$_9clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK4$_10clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK4$_11clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK4$_12clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK4$_13clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK4$_14clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
internal_service.cpp:_ZZZN5doris16PInternalServiceC1EPNS_7ExecEnvEENK4$_15clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
brpc_client_cache.cpp:_ZZZN5doris15BrpcClientCacheINS_20PBackendService_StubEEC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_S8_ENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
brpc_client_cache.cpp:_ZZZN5doris15BrpcClientCacheINS_20PBackendService_StubEEC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_S8_ENK3$_1clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
brpc_client_cache.cpp:_ZZZN5doris15BrpcClientCacheINS_21PFunctionService_StubEEC1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_S8_ENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
load_channel_mgr.cpp:_ZZZN5doris14LoadChannelMgrC1EvENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
tablets_channel.cpp:_ZZZZN5doris18BaseTabletsChannelC1ERKNS_17TabletsChannelKeyERKNS_8UniqueIdEbPNS_14RuntimeProfileEENK3$_0clEvENKUlvE_clEvENKUlvE_clEv
Line
Count
Source
35
959
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
memtable_memory_limiter.cpp:_ZZZN5doris21MemTableMemoryLimiter4initElENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
routine_load_task_executor.cpp:_ZZZN5doris23RoutineLoadTaskExecutorC1EPNS_7ExecEnvEENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
new_load_stream_mgr.cpp:_ZZZN5doris16NewLoadStreamMgrC1EvENK3$_0clEvENKUlvE_clEv
Line
Count
Source
35
1.01k
    entity->register_hook(#metric, [&]() { owner->metric->set_value(func()); });
36
37
#define REGISTER_HOOK_METRIC(metric, func)                                 \
38
754
    REGISTER_ENTITY_HOOK_METRIC(DorisMetrics::instance()->server_entity(), \
39
754
                                DorisMetrics::instance(), metric, func)
40
41
#define DEREGISTER_ENTITY_HOOK_METRIC(entity, name) \
42
673
    entity->deregister_metric(&METRIC_##name);      \
43
673
    entity->deregister_hook(#name);
44
45
#define DEREGISTER_HOOK_METRIC(name) \
46
673
    DEREGISTER_ENTITY_HOOK_METRIC(DorisMetrics::instance()->server_entity(), name)
47
48
class DorisMetrics {
49
public:
50
    IntCounter* fragment_requests_total = nullptr;
51
    IntCounter* fragment_request_duration_us = nullptr;
52
    IntCounter* query_scan_bytes = nullptr;
53
    IntCounter* query_scan_bytes_from_local = nullptr;
54
    IntCounter* query_scan_bytes_from_remote = nullptr;
55
    IntCounter* query_scan_rows = nullptr;
56
57
    // Query cache incremental merge (see runtime/query_cache/query_cache.h):
58
    // how many instance decisions reused a stale entry incrementally, how many
59
    // could have but fell back to a full recompute, and how many entries were
60
    // handed to the cache to be written back (the cache may still turn one
61
    // down: its LRU-K admission only keeps a key that comes back while the
62
    // shard is full). Per-query breakdown lives in the profile
63
    // (HitCacheStale / IncrementalFallbackReason / InsertCache).
64
    IntCounter* query_cache_stale_hit_total = nullptr;
65
    IntCounter* query_cache_incremental_fallback_total = nullptr;
66
    IntCounter* query_cache_write_back_total = nullptr;
67
68
    IntCounter* push_requests_success_total = nullptr;
69
    IntCounter* push_requests_fail_total = nullptr;
70
    IntCounter* push_request_duration_us = nullptr;
71
    IntCounter* push_request_write_bytes = nullptr;
72
    IntCounter* push_request_write_rows = nullptr;
73
    IntCounter* create_tablet_requests_total = nullptr;
74
    IntCounter* create_tablet_requests_failed = nullptr;
75
    IntCounter* drop_tablet_requests_total = nullptr;
76
77
    IntCounter* report_all_tablets_requests_skip = nullptr;
78
79
    IntCounter* schema_change_requests_total = nullptr;
80
    IntCounter* schema_change_requests_failed = nullptr;
81
    IntCounter* create_rollup_requests_total = nullptr;
82
    IntCounter* create_rollup_requests_failed = nullptr;
83
    IntCounter* storage_migrate_requests_total = nullptr;
84
    IntCounter* storage_migrate_v2_requests_total = nullptr;
85
    IntCounter* storage_migrate_v2_requests_failed = nullptr;
86
    IntCounter* delete_requests_total = nullptr;
87
    IntCounter* delete_requests_failed = nullptr;
88
    IntCounter* clone_requests_total = nullptr;
89
    IntCounter* clone_requests_failed = nullptr;
90
    IntCounter* alter_inverted_index_requests_total = nullptr;
91
    IntCounter* alter_inverted_index_requests_failed = nullptr;
92
93
    IntCounter* finish_task_requests_total = nullptr;
94
    IntCounter* finish_task_requests_failed = nullptr;
95
96
    IntCounter* compaction_producer_callback_a_round_time = nullptr;
97
98
    IntCounter* base_compaction_request_total = nullptr;
99
    IntCounter* base_compaction_request_failed = nullptr;
100
    IntCounter* cumulative_compaction_request_total = nullptr;
101
    IntCounter* cumulative_compaction_request_failed = nullptr;
102
103
    IntCounter* local_compaction_read_rows_total = nullptr;
104
    IntCounter* local_compaction_read_bytes_total = nullptr;
105
    IntCounter* local_compaction_write_rows_total = nullptr;
106
    IntCounter* local_compaction_write_bytes_total = nullptr;
107
    IntCounter* remote_compaction_read_rows_total = nullptr;
108
    IntCounter* remote_compaction_read_bytes_total = nullptr;
109
    IntCounter* remote_compaction_write_rows_total = nullptr;
110
    IntCounter* remote_compaction_write_bytes_total = nullptr;
111
112
    IntCounter* base_compaction_deltas_total = nullptr;
113
    IntCounter* base_compaction_bytes_total = nullptr;
114
    IntCounter* cumulative_compaction_deltas_total = nullptr;
115
    IntCounter* cumulative_compaction_bytes_total = nullptr;
116
    IntCounter* full_compaction_deltas_total = nullptr;
117
    IntCounter* full_compaction_bytes_total = nullptr;
118
119
    IntCounter* base_compaction_task_running_total = nullptr;
120
    IntCounter* base_compaction_task_pending_total = nullptr;
121
    IntCounter* binlog_compaction_task_running_total = nullptr;
122
    IntCounter* binlog_compaction_task_pending_total = nullptr;
123
    IntCounter* cumulative_compaction_task_running_total = nullptr;
124
    IntCounter* cumulative_compaction_task_pending_total = nullptr;
125
126
    IntCounter* publish_task_request_total = nullptr;
127
    IntCounter* publish_task_failed_total = nullptr;
128
129
    // Counters for segment_v2
130
    // -----------------------
131
    // total number of segments read
132
    IntCounter* segment_read_total = nullptr;
133
    // total number of rows in queried segments (before index pruning)
134
    IntCounter* segment_row_total = nullptr;
135
    // number of condition cache lookups when digest != 0
136
    IntCounter* condition_cache_search_count = nullptr;
137
    // number of condition cache hits
138
    IntCounter* condition_cache_hit_count = nullptr;
139
140
    IntCounter* stream_load_txn_begin_request_total = nullptr;
141
    IntCounter* stream_load_txn_commit_request_total = nullptr;
142
    IntCounter* stream_load_txn_rollback_request_total = nullptr;
143
    IntCounter* stream_receive_bytes_total = nullptr;
144
    IntCounter* stream_load_rows_total = nullptr;
145
    IntCounter* load_rows = nullptr;
146
    IntCounter* load_bytes = nullptr;
147
148
    IntCounter* routine_load_get_msg_latency = nullptr;
149
    IntCounter* routine_load_get_msg_count = nullptr;
150
    IntCounter* routine_load_consume_bytes = nullptr;
151
    IntCounter* routine_load_consume_rows = nullptr;
152
    IntCounter* routine_load_kinesis_get_records_latency = nullptr;
153
    IntCounter* routine_load_kinesis_get_records_count = nullptr;
154
    IntCounter* routine_load_kinesis_throttle_count = nullptr;
155
    IntCounter* routine_load_kinesis_retriable_error_count = nullptr;
156
    IntCounter* routine_load_kinesis_closed_shard_count = nullptr;
157
158
    IntCounter* memtable_flush_total = nullptr;
159
    IntCounter* memtable_flush_duration_us = nullptr;
160
161
    IntGauge* memory_pool_bytes_total = nullptr;
162
    IntGauge* process_thread_num = nullptr;
163
    IntGauge* process_fd_num_used = nullptr;
164
    IntGauge* process_fd_num_limit_soft = nullptr;
165
    IntGauge* process_fd_num_limit_hard = nullptr;
166
167
    // the max compaction score of all tablets.
168
    // Record base and cumulative scores separately, because
169
    // we need to get the larger of the two.
170
    IntGauge* tablet_cumulative_max_compaction_score = nullptr;
171
    IntGauge* tablet_base_max_compaction_score = nullptr;
172
    IntGauge* tablet_binlog_max_compaction_score = nullptr;
173
174
    IntGauge* all_rowsets_num = nullptr;
175
    IntGauge* all_segments_num = nullptr;
176
177
    // permits have been used for all compaction tasks
178
    IntGauge* compaction_used_permits = nullptr;
179
    IntGauge* binlog_compaction_used_permits = nullptr;
180
    // permits required by the compaction task which is waiting for permits
181
    IntGauge* compaction_waitting_permits = nullptr;
182
183
    HistogramMetric* tablet_version_num_distribution = nullptr;
184
185
    // The following metrics will be calculated
186
    // by metric calculator
187
    IntGauge* query_scan_bytes_per_second = nullptr;
188
189
    // Metrics related with file reader/writer
190
    IntCounter* local_file_reader_total = nullptr;
191
    IntCounter* s3_file_reader_total = nullptr;
192
    IntCounter* hdfs_file_reader_total = nullptr;
193
    IntCounter* broker_file_reader_total = nullptr;
194
    IntCounter* local_file_writer_total = nullptr;
195
    IntCounter* s3_file_writer_total = nullptr;
196
    IntCounter* file_created_total = nullptr;
197
    IntCounter* s3_file_created_total = nullptr;
198
    IntCounter* local_bytes_read_total = nullptr;
199
    IntCounter* s3_bytes_read_total = nullptr;
200
    IntCounter* local_bytes_written_total = nullptr;
201
    IntCounter* s3_bytes_written_total = nullptr;
202
    IntGauge* local_file_open_reading = nullptr;
203
    IntGauge* s3_file_open_reading = nullptr;
204
    IntGauge* hdfs_file_open_reading = nullptr;
205
    IntGauge* broker_file_open_reading = nullptr;
206
    IntGauge* local_file_open_writing = nullptr;
207
    IntGauge* s3_file_open_writing = nullptr;
208
209
    // Size of some global containers
210
    UIntGauge* rowset_count_generated_and_in_use = nullptr;
211
    UIntGauge* unused_rowsets_count = nullptr;
212
    UIntGauge* broker_count = nullptr;
213
    UIntGauge* data_stream_receiver_count = nullptr;
214
    UIntGauge* fragment_endpoint_count = nullptr;
215
    UIntGauge* active_scan_context_count = nullptr;
216
    UIntGauge* fragment_instance_count = nullptr;
217
    UIntGauge* load_channel_count = nullptr;
218
    UIntGauge* result_buffer_block_count = nullptr;
219
    UIntGauge* result_block_queue_count = nullptr;
220
    UIntGauge* routine_load_task_count = nullptr;
221
    UIntGauge* small_file_cache_count = nullptr;
222
    UIntGauge* stream_load_pipe_count = nullptr;
223
    UIntGauge* new_stream_load_pipe_count = nullptr;
224
    UIntGauge* brpc_endpoint_stub_count = nullptr;
225
    UIntGauge* brpc_stream_endpoint_stub_count = nullptr;
226
    UIntGauge* brpc_function_endpoint_stub_count = nullptr;
227
    UIntGauge* tablet_writer_count = nullptr;
228
229
    UIntGauge* segcompaction_mem_consumption = nullptr;
230
    UIntGauge* compaction_mem_consumption = nullptr;
231
    UIntGauge* load_mem_consumption = nullptr;
232
    UIntGauge* load_channel_mem_consumption = nullptr;
233
    UIntGauge* memtable_memory_limiter_mem_consumption = nullptr;
234
    UIntGauge* query_mem_consumption = nullptr;
235
    UIntGauge* schema_change_mem_consumption = nullptr;
236
    UIntGauge* storage_migration_mem_consumption = nullptr;
237
    UIntGauge* tablet_meta_mem_consumption = nullptr;
238
239
    // Cache metrics
240
    UIntGauge* query_cache_memory_total_byte = nullptr;
241
    UIntGauge* query_cache_sql_total_count = nullptr;
242
    UIntGauge* query_cache_partition_total_count = nullptr;
243
244
    // Upload metrics
245
    UIntGauge* upload_total_byte = nullptr;
246
    IntCounter* upload_rowset_count = nullptr;
247
    IntCounter* upload_fail_count = nullptr;
248
249
    UIntGauge* light_work_pool_queue_size = nullptr;
250
    UIntGauge* heavy_work_pool_queue_size = nullptr;
251
    UIntGauge* peer_fetch_work_pool_queue_size = nullptr;
252
    UIntGauge* heavy_work_active_threads = nullptr;
253
    UIntGauge* peer_fetch_work_active_threads = nullptr;
254
    UIntGauge* light_work_active_threads = nullptr;
255
256
    UIntGauge* heavy_work_pool_max_queue_size = nullptr;
257
    UIntGauge* peer_fetch_work_pool_max_queue_size = nullptr;
258
    UIntGauge* light_work_pool_max_queue_size = nullptr;
259
    UIntGauge* heavy_work_max_threads = nullptr;
260
    UIntGauge* peer_fetch_work_max_threads = nullptr;
261
    UIntGauge* light_work_max_threads = nullptr;
262
263
    UIntGauge* arrow_flight_work_pool_queue_size = nullptr;
264
    UIntGauge* arrow_flight_work_active_threads = nullptr;
265
    UIntGauge* arrow_flight_work_pool_max_queue_size = nullptr;
266
    UIntGauge* arrow_flight_work_max_threads = nullptr;
267
268
    IntCounter* num_io_bytes_read_total = nullptr;
269
    IntCounter* num_io_bytes_read_from_cache = nullptr;
270
    IntCounter* num_io_bytes_read_from_remote = nullptr;
271
    IntCounter* num_io_bytes_read_from_peer = nullptr;
272
    IntCounter* inverted_index_bytes_read_from_remote = nullptr;
273
    IntCounter* segment_footer_index_bytes_read_from_remote = nullptr;
274
275
    IntCounter* udf_close_bthread_count = nullptr;
276
277
    IntCounter* query_ctx_cnt = nullptr;
278
    IntCounter* scanner_ctx_cnt = nullptr;
279
    IntCounter* scanner_cnt = nullptr;
280
    IntCounter* scanner_task_cnt = nullptr;
281
    IntCounter* pipeline_task_queue_size = nullptr;
282
    IntCounter* ann_index_load_costs_ms = nullptr;
283
    IntCounter* ann_index_load_cnt = nullptr;
284
    IntCounter* ann_index_search_costs_ms = nullptr;
285
    IntCounter* ann_index_search_cnt = nullptr;
286
    IntCounter* ann_ivf_on_disk_fetch_page_costs_ms = nullptr;
287
    IntCounter* ann_ivf_on_disk_fetch_page_cnt = nullptr;
288
    IntCounter* ann_ivf_on_disk_search_costs_ms = nullptr;
289
    IntCounter* ann_ivf_on_disk_search_cnt = nullptr;
290
    IntCounter* ann_ivf_on_disk_cache_hit_cnt = nullptr;
291
    IntCounter* ann_ivf_on_disk_cache_miss_cnt = nullptr;
292
    IntCounter* ann_index_in_memory_cnt = nullptr;
293
    IntCounter* ann_index_in_memory_rows_cnt = nullptr;
294
    IntCounter* ann_index_construction = nullptr;
295
    IntCounter* ann_index_build_index_threads = nullptr;
296
297
    IntGauge* runtime_filter_consumer_num = nullptr;
298
    IntGauge* runtime_filter_consumer_ready_num = nullptr;
299
    IntCounter* runtime_filter_consumer_wait_ready_ms = nullptr;
300
    IntGauge* runtime_filter_consumer_timeout_num = nullptr;
301
302
    IntCounter* get_remote_tablet_slow_time_ms = nullptr;
303
    IntCounter* get_remote_tablet_slow_cnt = nullptr;
304
305
47.9M
    static DorisMetrics* instance() {
306
47.9M
        static DorisMetrics instance;
307
47.9M
        return &instance;
308
47.9M
    }
309
310
    // not thread-safe, call before calling metrics
311
    void initialize(
312
            bool init_system_metrics = false,
313
            const std::set<std::string>& disk_devices = std::set<std::string>(),
314
            const std::vector<std::string>& network_interfaces = std::vector<std::string>());
315
316
594k
    MetricRegistry* metric_registry() { return &_metric_registry; }
317
228k
    SystemMetrics* system_metrics() { return _system_metrics.get(); }
318
2.85k
    MetricEntity* server_entity() { return _server_metric_entity.get(); }
319
3.12k
    JvmMetrics* jvm_metrics() { return _jvm_metrics.get(); }
320
    void init_jvm_metrics();
321
322
private:
323
    // Don't allow constructor
324
    DorisMetrics();
325
326
    void _update();
327
    void _update_process_thread_num();
328
    void _update_process_fd_num();
329
330
private:
331
    static const std::string _s_registry_name;
332
    static const std::string _s_hook_name;
333
334
    MetricRegistry _metric_registry;
335
336
    std::unique_ptr<SystemMetrics> _system_metrics;
337
    std::unique_ptr<JvmMetrics> _jvm_metrics;
338
339
    std::shared_ptr<MetricEntity> _server_metric_entity;
340
};
341
342
}; // namespace doris