Skip to main content

risingwave_stream/executor/monitor/
streaming_stats.rs

1// Copyright 2022 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::sync::OnceLock;
16
17use prometheus::{
18    Histogram, IntCounter, IntGauge, Registry, exponential_buckets, histogram_opts,
19    register_histogram_with_registry, register_int_counter_with_registry,
20    register_int_gauge_with_registry,
21};
22use risingwave_common::catalog::TableId;
23use risingwave_common::config::MetricLevel;
24use risingwave_common::metrics::{
25    LabelGuardedHistogramVec, LabelGuardedIntCounter, LabelGuardedIntCounterVec,
26    LabelGuardedIntGauge, LabelGuardedIntGaugeVec, MetricVecRelabelExt,
27    RelabeledGuardedHistogramVec, RelabeledGuardedIntCounterVec, RelabeledGuardedIntGaugeVec,
28};
29use risingwave_common::monitor::GLOBAL_METRICS_REGISTRY;
30use risingwave_common::monitor::in_mem::CountMap;
31use risingwave_common::{
32    register_guarded_histogram_vec_with_registry, register_guarded_int_counter_vec_with_registry,
33    register_guarded_int_gauge_vec_with_registry,
34};
35use risingwave_connector::sink::catalog::SinkId;
36use risingwave_pb::id::ExecutorId;
37
38use crate::common::log_store_impl::kv_log_store::{
39    REWIND_BACKOFF_FACTOR, REWIND_BASE_DELAY, REWIND_MAX_DELAY,
40};
41use crate::executor::prelude::ActorId;
42use crate::task::FragmentId;
43
44#[derive(Clone)]
45pub struct StreamingMetrics {
46    pub level: MetricLevel,
47
48    // Executor metrics (disabled by default)
49    pub executor_row_count: RelabeledGuardedIntCounterVec,
50
51    // Profiling Metrics:
52    // Aggregated per operator rather than per actor.
53    // These are purely in-memory, never collected by prometheus.
54    pub mem_stream_node_output_row_count: CountMap<ExecutorId>,
55    pub mem_stream_node_output_blocking_duration_ns: CountMap<ExecutorId>,
56
57    // Streaming actor metrics from tokio (disabled by default)
58    actor_scheduled_duration: RelabeledGuardedIntCounterVec,
59    actor_scheduled_cnt: RelabeledGuardedIntCounterVec,
60    actor_poll_duration: RelabeledGuardedIntCounterVec,
61    actor_poll_cnt: RelabeledGuardedIntCounterVec,
62    actor_idle_duration: RelabeledGuardedIntCounterVec,
63    actor_idle_cnt: RelabeledGuardedIntCounterVec,
64
65    // Streaming actor
66    pub actor_count: LabelGuardedIntGaugeVec,
67    pub actor_in_record_cnt: RelabeledGuardedIntCounterVec,
68    pub actor_out_record_cnt: RelabeledGuardedIntCounterVec,
69    pub fragment_channel_buffered_bytes: LabelGuardedIntGaugeVec,
70    pub actor_current_epoch: RelabeledGuardedIntGaugeVec,
71    pub project_expr_inflight_window_size: LabelGuardedIntGaugeVec,
72
73    // Source
74    pub source_output_row_count: LabelGuardedIntCounterVec,
75    pub source_split_change_count: LabelGuardedIntCounterVec,
76    pub source_backfill_row_count: LabelGuardedIntCounterVec,
77
78    // Sink
79    sink_input_row_count: LabelGuardedIntCounterVec,
80    sink_input_bytes: LabelGuardedIntCounterVec,
81    sink_chunk_buffer_size: LabelGuardedIntGaugeVec,
82
83    // Exchange (see also `compute::ExchangeServiceMetrics`)
84    pub exchange_frag_recv_size: LabelGuardedIntCounterVec,
85
86    // Streaming Merge (We breakout this metric from `barrier_align_duration` because
87    // the alignment happens on different levels)
88    pub merge_barrier_align_duration: RelabeledGuardedIntCounterVec,
89
90    // Backpressure
91    pub actor_output_buffer_blocking_duration_ns: RelabeledGuardedIntCounterVec,
92    actor_input_buffer_blocking_duration_ns: RelabeledGuardedIntCounterVec,
93
94    // Streaming Join
95    pub join_lookup_miss_count: LabelGuardedIntCounterVec,
96    pub join_lookup_total_count: LabelGuardedIntCounterVec,
97    pub join_insert_cache_miss_count: LabelGuardedIntCounterVec,
98    pub join_actor_input_waiting_duration_ns: LabelGuardedIntCounterVec,
99    pub join_match_duration_ns: LabelGuardedIntCounterVec,
100    pub join_cached_entry_count: LabelGuardedIntGaugeVec,
101    pub join_matched_join_keys: RelabeledGuardedHistogramVec,
102
103    // Streaming Join, Streaming Dynamic Filter and Streaming Union
104    pub barrier_align_duration: RelabeledGuardedIntCounterVec,
105
106    // Streaming Aggregation
107    agg_lookup_miss_count: LabelGuardedIntCounterVec,
108    agg_total_lookup_count: LabelGuardedIntCounterVec,
109    agg_cached_entry_count: LabelGuardedIntGaugeVec,
110    agg_chunk_lookup_miss_count: LabelGuardedIntCounterVec,
111    agg_chunk_total_lookup_count: LabelGuardedIntCounterVec,
112    agg_dirty_groups_count: LabelGuardedIntGaugeVec,
113    agg_dirty_groups_heap_size: LabelGuardedIntGaugeVec,
114    agg_distinct_cache_miss_count: LabelGuardedIntCounterVec,
115    agg_distinct_total_cache_count: LabelGuardedIntCounterVec,
116    agg_distinct_cached_entry_count: LabelGuardedIntGaugeVec,
117    agg_state_cache_lookup_count: LabelGuardedIntCounterVec,
118    agg_state_cache_miss_count: LabelGuardedIntCounterVec,
119
120    // Streaming TopN
121    group_top_n_cache_miss_count: LabelGuardedIntCounterVec,
122    group_top_n_total_query_cache_count: LabelGuardedIntCounterVec,
123    group_top_n_cached_entry_count: LabelGuardedIntGaugeVec,
124    // TODO(rc): why not just use the above three?
125    group_top_n_appendonly_cache_miss_count: LabelGuardedIntCounterVec,
126    group_top_n_appendonly_total_query_cache_count: LabelGuardedIntCounterVec,
127    group_top_n_appendonly_cached_entry_count: LabelGuardedIntGaugeVec,
128
129    // Lookup executor
130    lookup_cache_miss_count: LabelGuardedIntCounterVec,
131    lookup_total_query_cache_count: LabelGuardedIntCounterVec,
132    lookup_cached_entry_count: LabelGuardedIntGaugeVec,
133
134    // temporal join
135    temporal_join_cache_miss_count: LabelGuardedIntCounterVec,
136    temporal_join_total_query_cache_count: LabelGuardedIntCounterVec,
137    temporal_join_cached_entry_count: LabelGuardedIntGaugeVec,
138
139    // Backfill
140    backfill_snapshot_read_row_count: LabelGuardedIntCounterVec,
141    backfill_upstream_output_row_count: LabelGuardedIntCounterVec,
142
143    // CDC Backfill
144    cdc_backfill_snapshot_read_row_count: LabelGuardedIntCounterVec,
145    cdc_backfill_upstream_output_row_count: LabelGuardedIntCounterVec,
146
147    // Snapshot Backfill
148    pub(crate) snapshot_backfill_consume_row_count: LabelGuardedIntCounterVec,
149
150    // Over Window
151    over_window_cached_entry_count: LabelGuardedIntGaugeVec,
152    over_window_cache_lookup_count: LabelGuardedIntCounterVec,
153    over_window_cache_miss_count: LabelGuardedIntCounterVec,
154    over_window_range_cache_entry_count: LabelGuardedIntGaugeVec,
155    over_window_range_cache_lookup_count: LabelGuardedIntCounterVec,
156    over_window_range_cache_left_miss_count: LabelGuardedIntCounterVec,
157    over_window_range_cache_right_miss_count: LabelGuardedIntCounterVec,
158    over_window_accessed_entry_count: LabelGuardedIntCounterVec,
159    over_window_compute_count: LabelGuardedIntCounterVec,
160    over_window_same_output_count: LabelGuardedIntCounterVec,
161
162    /// The duration from receipt of barrier to all actors collection.
163    /// And the max of all node `barrier_inflight_latency` is the latency for a barrier
164    /// to flow through the graph.
165    pub barrier_inflight_latency: Histogram,
166    /// The duration of sync to storage.
167    pub barrier_sync_latency: Histogram,
168    pub barrier_batch_size: Histogram,
169    /// The progress made by the earliest in-flight barriers in the local barrier manager.
170    pub barrier_manager_progress: IntCounter,
171
172    pub kv_log_store_storage_write_count: LabelGuardedIntCounterVec,
173    pub kv_log_store_storage_write_size: LabelGuardedIntCounterVec,
174    pub kv_log_store_rewind_count: LabelGuardedIntCounterVec,
175    pub kv_log_store_rewind_delay: LabelGuardedHistogramVec,
176    pub kv_log_store_storage_read_count: LabelGuardedIntCounterVec,
177    pub kv_log_store_storage_read_size: LabelGuardedIntCounterVec,
178    pub kv_log_store_buffer_unconsumed_item_count: LabelGuardedIntGaugeVec,
179    pub kv_log_store_buffer_unconsumed_row_count: LabelGuardedIntGaugeVec,
180    pub kv_log_store_buffer_unconsumed_epoch_count: LabelGuardedIntGaugeVec,
181    pub kv_log_store_buffer_unconsumed_min_epoch: LabelGuardedIntGaugeVec,
182    pub kv_log_store_buffer_memory_bytes: LabelGuardedIntGaugeVec,
183
184    pub crossdb_last_consumed_min_epoch: LabelGuardedIntGaugeVec,
185
186    pub sync_kv_log_store_read_count: LabelGuardedIntCounterVec,
187    pub sync_kv_log_store_read_size: LabelGuardedIntCounterVec,
188    pub sync_kv_log_store_write_pause_duration_ns: LabelGuardedIntCounterVec,
189    pub sync_kv_log_store_state: LabelGuardedIntCounterVec,
190    pub sync_kv_log_store_wait_next_poll_ns: LabelGuardedIntCounterVec,
191    pub sync_kv_log_store_storage_write_count: LabelGuardedIntCounterVec,
192    pub sync_kv_log_store_storage_write_size: LabelGuardedIntCounterVec,
193    pub sync_kv_log_store_buffer_unconsumed_item_count: LabelGuardedIntGaugeVec,
194    pub sync_kv_log_store_buffer_unconsumed_row_count: LabelGuardedIntGaugeVec,
195    pub sync_kv_log_store_buffer_unconsumed_epoch_count: LabelGuardedIntGaugeVec,
196    pub sync_kv_log_store_buffer_unconsumed_min_epoch: LabelGuardedIntGaugeVec,
197    pub sync_kv_log_store_buffer_memory_bytes: LabelGuardedIntGaugeVec,
198
199    // Memory management
200    pub lru_runtime_loop_count: IntCounter,
201    pub lru_latest_sequence: IntGauge,
202    pub lru_watermark_sequence: IntGauge,
203    pub lru_eviction_policy: IntGauge,
204    pub jemalloc_allocated_bytes: IntGauge,
205    pub jemalloc_active_bytes: IntGauge,
206    pub jemalloc_resident_bytes: IntGauge,
207    pub jemalloc_metadata_bytes: IntGauge,
208    pub jvm_allocated_bytes: IntGauge,
209    pub jvm_active_bytes: IntGauge,
210    pub stream_memory_usage: RelabeledGuardedIntGaugeVec,
211
212    // Materialized view
213    materialize_cache_hit_count: RelabeledGuardedIntCounterVec,
214    materialize_data_exist_count: RelabeledGuardedIntCounterVec,
215    materialize_cache_total_count: RelabeledGuardedIntCounterVec,
216    materialize_input_row_count: RelabeledGuardedIntCounterVec,
217    pub materialize_current_epoch: RelabeledGuardedIntGaugeVec,
218
219    // PostgreSQL CDC LSN monitoring
220    pub pg_cdc_state_table_lsn: LabelGuardedIntGaugeVec,
221    pub pg_cdc_jni_commit_offset_lsn: LabelGuardedIntGaugeVec,
222
223    // MySQL CDC binlog monitoring
224    pub mysql_cdc_state_binlog_file_seq: LabelGuardedIntGaugeVec,
225    pub mysql_cdc_state_binlog_position: LabelGuardedIntGaugeVec,
226
227    // SQL Server CDC LSN monitoring
228    pub sqlserver_cdc_state_change_lsn: LabelGuardedIntGaugeVec,
229    pub sqlserver_cdc_state_commit_lsn: LabelGuardedIntGaugeVec,
230    pub sqlserver_cdc_jni_commit_offset_lsn: LabelGuardedIntGaugeVec,
231
232    // Gap Fill
233    pub gap_fill_generated_rows_count: RelabeledGuardedIntCounterVec,
234
235    // State Table
236    pub state_table_iter_count: RelabeledGuardedIntCounterVec,
237    pub state_table_get_count: RelabeledGuardedIntCounterVec,
238    pub state_table_iter_vnode_pruned_count: RelabeledGuardedIntCounterVec,
239    pub state_table_get_vnode_pruned_count: RelabeledGuardedIntCounterVec,
240}
241
242pub static GLOBAL_STREAMING_METRICS: OnceLock<StreamingMetrics> = OnceLock::new();
243
244pub fn global_streaming_metrics(metric_level: MetricLevel) -> StreamingMetrics {
245    GLOBAL_STREAMING_METRICS
246        .get_or_init(|| StreamingMetrics::new(&GLOBAL_METRICS_REGISTRY, metric_level))
247        .clone()
248}
249
250impl StreamingMetrics {
251    pub fn new(registry: &Registry, level: MetricLevel) -> Self {
252        let executor_row_count = register_guarded_int_counter_vec_with_registry!(
253            "stream_executor_row_count",
254            "Total number of rows that have been output from each executor",
255            &["actor_id", "fragment_id", "executor_identity"],
256            registry
257        )
258        .unwrap()
259        .relabel_debug_1(level);
260
261        let stream_node_output_row_count = CountMap::new();
262        let stream_node_output_blocking_duration_ns = CountMap::new();
263
264        let source_output_row_count = register_guarded_int_counter_vec_with_registry!(
265            "stream_source_output_rows_counts",
266            "Total number of rows that have been output from source",
267            &["source_id", "source_name", "actor_id", "fragment_id"],
268            registry
269        )
270        .unwrap();
271
272        let source_split_change_count = register_guarded_int_counter_vec_with_registry!(
273            "stream_source_split_change_event_count",
274            "Total number of split change events that have been operated by source",
275            &["source_id", "source_name", "actor_id", "fragment_id"],
276            registry
277        )
278        .unwrap();
279
280        let source_backfill_row_count = register_guarded_int_counter_vec_with_registry!(
281            "stream_source_backfill_rows_counts",
282            "Total number of rows that have been backfilled for source",
283            &["source_id", "source_name", "actor_id", "fragment_id"],
284            registry
285        )
286        .unwrap();
287
288        let sink_input_row_count = register_guarded_int_counter_vec_with_registry!(
289            "stream_sink_input_row_count",
290            "Total number of rows streamed into sink executors",
291            &["sink_id", "actor_id", "fragment_id"],
292            registry
293        )
294        .unwrap();
295
296        let sink_input_bytes = register_guarded_int_counter_vec_with_registry!(
297            "stream_sink_input_bytes",
298            "Total size of chunks streamed into sink executors",
299            &["sink_id", "actor_id", "fragment_id"],
300            registry
301        )
302        .unwrap();
303
304        let materialize_input_row_count = register_guarded_int_counter_vec_with_registry!(
305            "stream_mview_input_row_count",
306            "Total number of rows streamed into materialize executors",
307            &["actor_id", "table_id", "fragment_id"],
308            registry
309        )
310        .unwrap()
311        .relabel_debug_1(level);
312
313        let materialize_current_epoch = register_guarded_int_gauge_vec_with_registry!(
314            "stream_mview_current_epoch",
315            "The current epoch of the materialized executor",
316            &["actor_id", "table_id", "fragment_id"],
317            registry
318        )
319        .unwrap()
320        .relabel_debug_1(level);
321
322        let pg_cdc_state_table_lsn = register_guarded_int_gauge_vec_with_registry!(
323            "stream_pg_cdc_state_table_lsn",
324            "Current LSN value stored in PostgreSQL CDC state table",
325            &["source_id"],
326            registry,
327        )
328        .unwrap();
329
330        let pg_cdc_jni_commit_offset_lsn = register_guarded_int_gauge_vec_with_registry!(
331            "stream_pg_cdc_jni_commit_offset_lsn",
332            "LSN value when JNI commit offset is called for PostgreSQL CDC",
333            &["source_id"],
334            registry,
335        )
336        .unwrap();
337
338        let mysql_cdc_state_binlog_file_seq = register_guarded_int_gauge_vec_with_registry!(
339            "stream_mysql_cdc_state_binlog_file_seq",
340            "Current binlog file sequence number stored in MySQL CDC state table",
341            &["source_id"],
342            registry,
343        )
344        .unwrap();
345
346        let mysql_cdc_state_binlog_position = register_guarded_int_gauge_vec_with_registry!(
347            "stream_mysql_cdc_state_binlog_position",
348            "Current binlog position stored in MySQL CDC state table",
349            &["source_id"],
350            registry,
351        )
352        .unwrap();
353
354        let sqlserver_cdc_state_change_lsn = register_guarded_int_gauge_vec_with_registry!(
355            "stream_sqlserver_cdc_state_change_lsn",
356            "Current change_lsn value stored in SQL Server CDC state table",
357            &["source_id"],
358            registry,
359        )
360        .unwrap();
361
362        let sqlserver_cdc_state_commit_lsn = register_guarded_int_gauge_vec_with_registry!(
363            "stream_sqlserver_cdc_state_commit_lsn",
364            "Current commit_lsn value stored in SQL Server CDC state table",
365            &["source_id"],
366            registry,
367        )
368        .unwrap();
369
370        let sqlserver_cdc_jni_commit_offset_lsn = register_guarded_int_gauge_vec_with_registry!(
371            "stream_sqlserver_cdc_jni_commit_offset_lsn",
372            "LSN value when JNI commit offset is called for SQL Server CDC",
373            &["source_id"],
374            registry,
375        )
376        .unwrap();
377
378        let sink_chunk_buffer_size = register_guarded_int_gauge_vec_with_registry!(
379            "stream_sink_chunk_buffer_size",
380            "Total size of chunks buffered in a barrier",
381            &["sink_id", "actor_id", "fragment_id"],
382            registry
383        )
384        .unwrap();
385        let actor_output_buffer_blocking_duration_ns =
386            register_guarded_int_counter_vec_with_registry!(
387                "stream_actor_output_buffer_blocking_duration_ns",
388                "Total blocking duration (ns) of output buffer",
389                &["actor_id", "fragment_id", "downstream_fragment_id"],
390                registry
391            )
392            .unwrap()
393            // mask the first label `actor_id` if the level is less verbose than `Debug`
394            .relabel_debug_1(level);
395
396        let actor_input_buffer_blocking_duration_ns =
397            register_guarded_int_counter_vec_with_registry!(
398                "stream_actor_input_buffer_blocking_duration_ns",
399                "Total blocking duration (ns) of input buffer",
400                &["actor_id", "fragment_id", "upstream_fragment_id"],
401                registry
402            )
403            .unwrap()
404            // mask the first label `actor_id` if the level is less verbose than `Debug`
405            .relabel_debug_1(level);
406
407        let fragment_channel_buffered_bytes = register_guarded_int_gauge_vec_with_registry!(
408            "stream_fragment_channel_buffered_bytes",
409            "Estimated buffered bytes for actor channels by fragment",
410            &["fragment_id"],
411            registry
412        )
413        .unwrap();
414
415        let exchange_frag_recv_size = register_guarded_int_counter_vec_with_registry!(
416            "stream_exchange_frag_recv_size",
417            "Total size of messages that have been received from upstream Fragment",
418            &["up_fragment_id", "down_fragment_id"],
419            registry
420        )
421        .unwrap();
422
423        let actor_poll_duration = register_guarded_int_counter_vec_with_registry!(
424            "stream_actor_poll_duration",
425            "tokio's metrics",
426            &["actor_id", "fragment_id"],
427            registry
428        )
429        .unwrap()
430        .relabel_debug_1(level);
431
432        let actor_poll_cnt = register_guarded_int_counter_vec_with_registry!(
433            "stream_actor_poll_cnt",
434            "tokio's metrics",
435            &["actor_id", "fragment_id"],
436            registry
437        )
438        .unwrap()
439        .relabel_debug_1(level);
440
441        let actor_scheduled_duration = register_guarded_int_counter_vec_with_registry!(
442            "stream_actor_scheduled_duration",
443            "tokio's metrics",
444            &["actor_id", "fragment_id"],
445            registry
446        )
447        .unwrap()
448        .relabel_debug_1(level);
449
450        let actor_scheduled_cnt = register_guarded_int_counter_vec_with_registry!(
451            "stream_actor_scheduled_cnt",
452            "tokio's metrics",
453            &["actor_id", "fragment_id"],
454            registry
455        )
456        .unwrap()
457        .relabel_debug_1(level);
458
459        let actor_idle_duration = register_guarded_int_counter_vec_with_registry!(
460            "stream_actor_idle_duration",
461            "tokio's metrics",
462            &["actor_id", "fragment_id"],
463            registry
464        )
465        .unwrap()
466        .relabel_debug_1(level);
467
468        let actor_idle_cnt = register_guarded_int_counter_vec_with_registry!(
469            "stream_actor_idle_cnt",
470            "tokio's metrics",
471            &["actor_id", "fragment_id"],
472            registry
473        )
474        .unwrap()
475        .relabel_debug_1(level);
476
477        let actor_in_record_cnt = register_guarded_int_counter_vec_with_registry!(
478            "stream_actor_in_record_cnt",
479            "Total number of rows actor received",
480            &["actor_id", "fragment_id", "upstream_fragment_id"],
481            registry
482        )
483        .unwrap()
484        .relabel_debug_1(level);
485
486        let actor_out_record_cnt = register_guarded_int_counter_vec_with_registry!(
487            "stream_actor_out_record_cnt",
488            "Total number of rows actor sent",
489            &["actor_id", "fragment_id"],
490            registry
491        )
492        .unwrap()
493        .relabel_debug_1(level);
494
495        let actor_current_epoch = register_guarded_int_gauge_vec_with_registry!(
496            "stream_actor_current_epoch",
497            "Current epoch of actor",
498            &["actor_id", "fragment_id"],
499            registry
500        )
501        .unwrap()
502        .relabel_debug_1(level);
503
504        let project_expr_inflight_window_size = register_guarded_int_gauge_vec_with_registry!(
505            "stream_project_expr_inflight_window_size",
506            "Number of messages waiting in ProjectExecutor's ordered projection window",
507            &["actor_id", "fragment_id"],
508            registry
509        )
510        .unwrap();
511
512        let actor_count = register_guarded_int_gauge_vec_with_registry!(
513            "stream_actor_count",
514            "Total number of actors (parallelism)",
515            &["fragment_id"],
516            registry
517        )
518        .unwrap();
519
520        let merge_barrier_align_duration = register_guarded_int_counter_vec_with_registry!(
521            "stream_merge_barrier_align_duration_ns",
522            "Total merge barrier alignment duration (ns)",
523            &["actor_id", "fragment_id"],
524            registry
525        )
526        .unwrap()
527        .relabel_debug_1(level);
528
529        let join_lookup_miss_count = register_guarded_int_counter_vec_with_registry!(
530            "stream_join_lookup_miss_count",
531            "Join executor lookup miss duration",
532            &["side", "join_table_id", "actor_id", "fragment_id"],
533            registry
534        )
535        .unwrap();
536
537        let join_lookup_total_count = register_guarded_int_counter_vec_with_registry!(
538            "stream_join_lookup_total_count",
539            "Join executor lookup total operation",
540            &["side", "join_table_id", "actor_id", "fragment_id"],
541            registry
542        )
543        .unwrap();
544
545        let join_insert_cache_miss_count = register_guarded_int_counter_vec_with_registry!(
546            "stream_join_insert_cache_miss_count",
547            "Join executor cache miss when insert operation",
548            &["side", "join_table_id", "actor_id", "fragment_id"],
549            registry
550        )
551        .unwrap();
552
553        let join_actor_input_waiting_duration_ns = register_guarded_int_counter_vec_with_registry!(
554            "stream_join_actor_input_waiting_duration_ns",
555            "Total waiting duration (ns) of input buffer of join actor",
556            &["actor_id", "fragment_id"],
557            registry
558        )
559        .unwrap();
560
561        let join_match_duration_ns = register_guarded_int_counter_vec_with_registry!(
562            "stream_join_match_duration_ns",
563            "Matching duration for each side",
564            &["actor_id", "fragment_id", "side"],
565            registry
566        )
567        .unwrap();
568
569        let barrier_align_duration = register_guarded_int_counter_vec_with_registry!(
570            "stream_barrier_align_duration_ns",
571            "Duration of join align barrier",
572            &["actor_id", "fragment_id", "wait_side", "executor"],
573            registry
574        )
575        .unwrap()
576        .relabel_debug_1(level);
577
578        let join_cached_entry_count = register_guarded_int_gauge_vec_with_registry!(
579            "stream_join_cached_entry_count",
580            "Number of cached entries in streaming join operators",
581            &["actor_id", "fragment_id", "side"],
582            registry
583        )
584        .unwrap();
585
586        let join_matched_join_keys_opts = histogram_opts!(
587            "stream_join_matched_join_keys",
588            "The number of keys matched in the opposite side",
589            exponential_buckets(16.0, 2.0, 28).unwrap() // max 2^31
590        );
591
592        let join_matched_join_keys = register_guarded_histogram_vec_with_registry!(
593            join_matched_join_keys_opts,
594            &["actor_id", "fragment_id", "table_id"],
595            registry
596        )
597        .unwrap()
598        .relabel_debug_1(level);
599
600        let agg_lookup_miss_count = register_guarded_int_counter_vec_with_registry!(
601            "stream_agg_lookup_miss_count",
602            "Aggregation executor lookup miss duration",
603            &["table_id", "actor_id", "fragment_id"],
604            registry
605        )
606        .unwrap();
607
608        let agg_total_lookup_count = register_guarded_int_counter_vec_with_registry!(
609            "stream_agg_lookup_total_count",
610            "Aggregation executor lookup total operation",
611            &["table_id", "actor_id", "fragment_id"],
612            registry
613        )
614        .unwrap();
615
616        let agg_distinct_cache_miss_count = register_guarded_int_counter_vec_with_registry!(
617            "stream_agg_distinct_cache_miss_count",
618            "Aggregation executor dinsinct miss duration",
619            &["table_id", "actor_id", "fragment_id"],
620            registry
621        )
622        .unwrap();
623
624        let agg_distinct_total_cache_count = register_guarded_int_counter_vec_with_registry!(
625            "stream_agg_distinct_total_cache_count",
626            "Aggregation executor distinct total operation",
627            &["table_id", "actor_id", "fragment_id"],
628            registry
629        )
630        .unwrap();
631
632        let agg_distinct_cached_entry_count = register_guarded_int_gauge_vec_with_registry!(
633            "stream_agg_distinct_cached_entry_count",
634            "Total entry counts in distinct aggregation executor cache",
635            &["table_id", "actor_id", "fragment_id"],
636            registry
637        )
638        .unwrap();
639
640        let agg_dirty_groups_count = register_guarded_int_gauge_vec_with_registry!(
641            "stream_agg_dirty_groups_count",
642            "Total dirty group counts in aggregation executor",
643            &["table_id", "actor_id", "fragment_id"],
644            registry
645        )
646        .unwrap();
647
648        let agg_dirty_groups_heap_size = register_guarded_int_gauge_vec_with_registry!(
649            "stream_agg_dirty_groups_heap_size",
650            "Total dirty group heap size in aggregation executor",
651            &["table_id", "actor_id", "fragment_id"],
652            registry
653        )
654        .unwrap();
655
656        let agg_state_cache_lookup_count = register_guarded_int_counter_vec_with_registry!(
657            "stream_agg_state_cache_lookup_count",
658            "Aggregation executor state cache lookup count",
659            &["table_id", "actor_id", "fragment_id"],
660            registry
661        )
662        .unwrap();
663
664        let agg_state_cache_miss_count = register_guarded_int_counter_vec_with_registry!(
665            "stream_agg_state_cache_miss_count",
666            "Aggregation executor state cache miss count",
667            &["table_id", "actor_id", "fragment_id"],
668            registry
669        )
670        .unwrap();
671
672        let group_top_n_cache_miss_count = register_guarded_int_counter_vec_with_registry!(
673            "stream_group_top_n_cache_miss_count",
674            "Group top n executor cache miss count",
675            &["table_id", "actor_id", "fragment_id"],
676            registry
677        )
678        .unwrap();
679
680        let group_top_n_total_query_cache_count = register_guarded_int_counter_vec_with_registry!(
681            "stream_group_top_n_total_query_cache_count",
682            "Group top n executor query cache total count",
683            &["table_id", "actor_id", "fragment_id"],
684            registry
685        )
686        .unwrap();
687
688        let group_top_n_cached_entry_count = register_guarded_int_gauge_vec_with_registry!(
689            "stream_group_top_n_cached_entry_count",
690            "Total entry counts in group top n executor cache",
691            &["table_id", "actor_id", "fragment_id"],
692            registry
693        )
694        .unwrap();
695
696        let group_top_n_appendonly_cache_miss_count =
697            register_guarded_int_counter_vec_with_registry!(
698                "stream_group_top_n_appendonly_cache_miss_count",
699                "Group top n appendonly executor cache miss count",
700                &["table_id", "actor_id", "fragment_id"],
701                registry
702            )
703            .unwrap();
704
705        let group_top_n_appendonly_total_query_cache_count =
706            register_guarded_int_counter_vec_with_registry!(
707                "stream_group_top_n_appendonly_total_query_cache_count",
708                "Group top n appendonly executor total cache count",
709                &["table_id", "actor_id", "fragment_id"],
710                registry
711            )
712            .unwrap();
713
714        let group_top_n_appendonly_cached_entry_count =
715            register_guarded_int_gauge_vec_with_registry!(
716                "stream_group_top_n_appendonly_cached_entry_count",
717                "Total entry counts in group top n appendonly executor cache",
718                &["table_id", "actor_id", "fragment_id"],
719                registry
720            )
721            .unwrap();
722
723        let lookup_cache_miss_count = register_guarded_int_counter_vec_with_registry!(
724            "stream_lookup_cache_miss_count",
725            "Lookup executor cache miss count",
726            &["table_id", "actor_id", "fragment_id"],
727            registry
728        )
729        .unwrap();
730
731        let lookup_total_query_cache_count = register_guarded_int_counter_vec_with_registry!(
732            "stream_lookup_total_query_cache_count",
733            "Lookup executor query cache total count",
734            &["table_id", "actor_id", "fragment_id"],
735            registry
736        )
737        .unwrap();
738
739        let lookup_cached_entry_count = register_guarded_int_gauge_vec_with_registry!(
740            "stream_lookup_cached_entry_count",
741            "Total entry counts in lookup executor cache",
742            &["table_id", "actor_id", "fragment_id"],
743            registry
744        )
745        .unwrap();
746
747        let temporal_join_cache_miss_count = register_guarded_int_counter_vec_with_registry!(
748            "stream_temporal_join_cache_miss_count",
749            "Temporal join executor cache miss count",
750            &["table_id", "actor_id", "fragment_id"],
751            registry
752        )
753        .unwrap();
754
755        let temporal_join_total_query_cache_count =
756            register_guarded_int_counter_vec_with_registry!(
757                "stream_temporal_join_total_query_cache_count",
758                "Temporal join executor query cache total count",
759                &["table_id", "actor_id", "fragment_id"],
760                registry
761            )
762            .unwrap();
763
764        let temporal_join_cached_entry_count = register_guarded_int_gauge_vec_with_registry!(
765            "stream_temporal_join_cached_entry_count",
766            "Total entry count in temporal join executor cache",
767            &["table_id", "actor_id", "fragment_id"],
768            registry
769        )
770        .unwrap();
771
772        let agg_cached_entry_count = register_guarded_int_gauge_vec_with_registry!(
773            "stream_agg_cached_entry_count",
774            "Number of cached keys in streaming aggregation operators",
775            &["table_id", "actor_id", "fragment_id"],
776            registry
777        )
778        .unwrap();
779
780        let agg_chunk_lookup_miss_count = register_guarded_int_counter_vec_with_registry!(
781            "stream_agg_chunk_lookup_miss_count",
782            "Aggregation executor chunk-level lookup miss duration",
783            &["table_id", "actor_id", "fragment_id"],
784            registry
785        )
786        .unwrap();
787
788        let agg_chunk_total_lookup_count = register_guarded_int_counter_vec_with_registry!(
789            "stream_agg_chunk_lookup_total_count",
790            "Aggregation executor chunk-level lookup total operation",
791            &["table_id", "actor_id", "fragment_id"],
792            registry
793        )
794        .unwrap();
795
796        let backfill_snapshot_read_row_count = register_guarded_int_counter_vec_with_registry!(
797            "stream_backfill_snapshot_read_row_count",
798            "Total number of rows that have been read from the backfill snapshot",
799            &["table_id", "actor_id"],
800            registry
801        )
802        .unwrap();
803
804        let backfill_upstream_output_row_count = register_guarded_int_counter_vec_with_registry!(
805            "stream_backfill_upstream_output_row_count",
806            "Total number of rows that have been output from the backfill upstream",
807            &["table_id", "actor_id"],
808            registry
809        )
810        .unwrap();
811
812        let cdc_backfill_snapshot_read_row_count = register_guarded_int_counter_vec_with_registry!(
813            "stream_cdc_backfill_snapshot_read_row_count",
814            "Total number of rows that have been read from the cdc_backfill snapshot",
815            &["table_id", "actor_id"],
816            registry
817        )
818        .unwrap();
819
820        let cdc_backfill_upstream_output_row_count =
821            register_guarded_int_counter_vec_with_registry!(
822                "stream_cdc_backfill_upstream_output_row_count",
823                "Total number of rows that have been output from the cdc_backfill upstream",
824                &["table_id", "actor_id"],
825                registry
826            )
827            .unwrap();
828
829        let snapshot_backfill_consume_row_count = register_guarded_int_counter_vec_with_registry!(
830            "stream_snapshot_backfill_consume_snapshot_row_count",
831            "Total number of rows that have been output from snapshot backfill",
832            &["table_id", "actor_id", "stage"],
833            registry
834        )
835        .unwrap();
836
837        let over_window_cached_entry_count = register_guarded_int_gauge_vec_with_registry!(
838            "stream_over_window_cached_entry_count",
839            "Total entry (partition) count in over window executor cache",
840            &["table_id", "actor_id", "fragment_id"],
841            registry
842        )
843        .unwrap();
844
845        let over_window_cache_lookup_count = register_guarded_int_counter_vec_with_registry!(
846            "stream_over_window_cache_lookup_count",
847            "Over window executor cache lookup count",
848            &["table_id", "actor_id", "fragment_id"],
849            registry
850        )
851        .unwrap();
852
853        let over_window_cache_miss_count = register_guarded_int_counter_vec_with_registry!(
854            "stream_over_window_cache_miss_count",
855            "Over window executor cache miss count",
856            &["table_id", "actor_id", "fragment_id"],
857            registry
858        )
859        .unwrap();
860
861        let over_window_range_cache_entry_count = register_guarded_int_gauge_vec_with_registry!(
862            "stream_over_window_range_cache_entry_count",
863            "Over window partition range cache entry count",
864            &["table_id", "actor_id", "fragment_id"],
865            registry,
866        )
867        .unwrap();
868
869        let over_window_range_cache_lookup_count = register_guarded_int_counter_vec_with_registry!(
870            "stream_over_window_range_cache_lookup_count",
871            "Over window partition range cache lookup count",
872            &["table_id", "actor_id", "fragment_id"],
873            registry
874        )
875        .unwrap();
876
877        let over_window_range_cache_left_miss_count =
878            register_guarded_int_counter_vec_with_registry!(
879                "stream_over_window_range_cache_left_miss_count",
880                "Over window partition range cache left miss count",
881                &["table_id", "actor_id", "fragment_id"],
882                registry
883            )
884            .unwrap();
885
886        let over_window_range_cache_right_miss_count =
887            register_guarded_int_counter_vec_with_registry!(
888                "stream_over_window_range_cache_right_miss_count",
889                "Over window partition range cache right miss count",
890                &["table_id", "actor_id", "fragment_id"],
891                registry
892            )
893            .unwrap();
894
895        let over_window_accessed_entry_count = register_guarded_int_counter_vec_with_registry!(
896            "stream_over_window_accessed_entry_count",
897            "Over window accessed entry count",
898            &["table_id", "actor_id", "fragment_id"],
899            registry
900        )
901        .unwrap();
902
903        let over_window_compute_count = register_guarded_int_counter_vec_with_registry!(
904            "stream_over_window_compute_count",
905            "Over window compute count",
906            &["table_id", "actor_id", "fragment_id"],
907            registry
908        )
909        .unwrap();
910
911        let over_window_same_output_count = register_guarded_int_counter_vec_with_registry!(
912            "stream_over_window_same_output_count",
913            "Over window same output count",
914            &["table_id", "actor_id", "fragment_id"],
915            registry
916        )
917        .unwrap();
918
919        let opts = histogram_opts!(
920            "stream_barrier_inflight_duration_seconds",
921            "barrier_inflight_latency",
922            exponential_buckets(0.1, 1.5, 16).unwrap() // max 43s
923        );
924        let barrier_inflight_latency = register_histogram_with_registry!(opts, registry).unwrap();
925
926        let opts = histogram_opts!(
927            "stream_barrier_sync_storage_duration_seconds",
928            "barrier_sync_latency",
929            exponential_buckets(0.1, 1.5, 16).unwrap() // max 43
930        );
931        let barrier_sync_latency = register_histogram_with_registry!(opts, registry).unwrap();
932
933        let opts = histogram_opts!(
934            "stream_barrier_batch_size",
935            "barrier_batch_size",
936            exponential_buckets(1.0, 2.0, 8).unwrap()
937        );
938        let barrier_batch_size = register_histogram_with_registry!(opts, registry).unwrap();
939
940        let barrier_manager_progress = register_int_counter_with_registry!(
941            "stream_barrier_manager_progress",
942            "The number of actors that have processed the earliest in-flight barriers",
943            registry
944        )
945        .unwrap();
946
947        let sync_kv_log_store_wait_next_poll_ns = register_guarded_int_counter_vec_with_registry!(
948            "sync_kv_log_store_wait_next_poll_ns",
949            "Total duration (ns) of waiting for next poll",
950            &["actor_id", "target", "fragment_id", "relation"],
951            registry
952        )
953        .unwrap();
954
955        let sync_kv_log_store_read_count = register_guarded_int_counter_vec_with_registry!(
956            "sync_kv_log_store_read_count",
957            "read row count throughput of sync_kv log store",
958            &["type", "actor_id", "target", "fragment_id", "relation"],
959            registry
960        )
961        .unwrap();
962
963        let sync_kv_log_store_read_size = register_guarded_int_counter_vec_with_registry!(
964            "sync_kv_log_store_read_size",
965            "read size throughput of sync_kv log store",
966            &["type", "actor_id", "target", "fragment_id", "relation"],
967            registry
968        )
969        .unwrap();
970
971        let sync_kv_log_store_write_pause_duration_ns =
972            register_guarded_int_counter_vec_with_registry!(
973                "sync_kv_log_store_write_pause_duration_ns",
974                "Duration (ns) of sync_kv log store write pause",
975                &["actor_id", "target", "fragment_id", "relation"],
976                registry
977            )
978            .unwrap();
979
980        let sync_kv_log_store_state = register_guarded_int_counter_vec_with_registry!(
981            "sync_kv_log_store_state",
982            "clean/unclean state transition for sync_kv log store",
983            &["state", "actor_id", "target", "fragment_id", "relation"],
984            registry
985        )
986        .unwrap();
987
988        let sync_kv_log_store_storage_write_count =
989            register_guarded_int_counter_vec_with_registry!(
990                "sync_kv_log_store_storage_write_count",
991                "Write row count throughput of sync_kv log store",
992                &["actor_id", "target", "fragment_id", "relation"],
993                registry
994            )
995            .unwrap();
996
997        let sync_kv_log_store_storage_write_size = register_guarded_int_counter_vec_with_registry!(
998            "sync_kv_log_store_storage_write_size",
999            "Write size throughput of sync_kv log store",
1000            &["actor_id", "target", "fragment_id", "relation"],
1001            registry
1002        )
1003        .unwrap();
1004
1005        let sync_kv_log_store_buffer_unconsumed_item_count =
1006            register_guarded_int_gauge_vec_with_registry!(
1007                "sync_kv_log_store_buffer_unconsumed_item_count",
1008                "Number of Unconsumed Item in buffer",
1009                &["actor_id", "target", "fragment_id", "relation"],
1010                registry
1011            )
1012            .unwrap();
1013
1014        let sync_kv_log_store_buffer_unconsumed_row_count =
1015            register_guarded_int_gauge_vec_with_registry!(
1016                "sync_kv_log_store_buffer_unconsumed_row_count",
1017                "Number of Unconsumed Row in buffer",
1018                &["actor_id", "target", "fragment_id", "relation"],
1019                registry
1020            )
1021            .unwrap();
1022
1023        let sync_kv_log_store_buffer_unconsumed_epoch_count =
1024            register_guarded_int_gauge_vec_with_registry!(
1025                "sync_kv_log_store_buffer_unconsumed_epoch_count",
1026                "Number of Unconsumed Epoch in buffer",
1027                &["actor_id", "target", "fragment_id", "relation"],
1028                registry
1029            )
1030            .unwrap();
1031
1032        let sync_kv_log_store_buffer_unconsumed_min_epoch =
1033            register_guarded_int_gauge_vec_with_registry!(
1034                "sync_kv_log_store_buffer_unconsumed_min_epoch",
1035                "Number of Unconsumed Epoch in buffer",
1036                &["actor_id", "target", "fragment_id", "relation"],
1037                registry
1038            )
1039            .unwrap();
1040        let sync_kv_log_store_buffer_memory_bytes =
1041            register_guarded_int_gauge_vec_with_registry!(
1042                "sync_kv_log_store_buffer_memory_bytes",
1043                "Estimated heap bytes used by synced kv log store buffer (unconsumed + consumed but not truncated)",
1044                &["actor_id", "target", "fragment_id", "relation"],
1045                registry
1046            )
1047            .unwrap();
1048
1049        let kv_log_store_storage_write_count = register_guarded_int_counter_vec_with_registry!(
1050            "kv_log_store_storage_write_count",
1051            "Write row count throughput of kv log store",
1052            &["actor_id", "connector", "sink_id", "sink_name"],
1053            registry
1054        )
1055        .unwrap();
1056
1057        let kv_log_store_storage_write_size = register_guarded_int_counter_vec_with_registry!(
1058            "kv_log_store_storage_write_size",
1059            "Write size throughput of kv log store",
1060            &["actor_id", "connector", "sink_id", "sink_name"],
1061            registry
1062        )
1063        .unwrap();
1064
1065        let kv_log_store_storage_read_count = register_guarded_int_counter_vec_with_registry!(
1066            "kv_log_store_storage_read_count",
1067            "Write row count throughput of kv log store",
1068            &["actor_id", "connector", "sink_id", "sink_name", "read_type"],
1069            registry
1070        )
1071        .unwrap();
1072
1073        let kv_log_store_storage_read_size = register_guarded_int_counter_vec_with_registry!(
1074            "kv_log_store_storage_read_size",
1075            "Write size throughput of kv log store",
1076            &["actor_id", "connector", "sink_id", "sink_name", "read_type"],
1077            registry
1078        )
1079        .unwrap();
1080
1081        let kv_log_store_rewind_count = register_guarded_int_counter_vec_with_registry!(
1082            "kv_log_store_rewind_count",
1083            "Kv log store rewind rate",
1084            &["actor_id", "connector", "sink_id", "sink_name"],
1085            registry
1086        )
1087        .unwrap();
1088
1089        let kv_log_store_rewind_delay_opts = {
1090            assert_eq!(2, REWIND_BACKOFF_FACTOR);
1091            let bucket_count = (REWIND_MAX_DELAY.as_secs_f64().log2()
1092                - REWIND_BASE_DELAY.as_secs_f64().log2())
1093            .ceil() as usize;
1094            let buckets = exponential_buckets(
1095                REWIND_BASE_DELAY.as_secs_f64(),
1096                REWIND_BACKOFF_FACTOR as _,
1097                bucket_count,
1098            )
1099            .unwrap();
1100            histogram_opts!(
1101                "kv_log_store_rewind_delay",
1102                "Kv log store rewind delay",
1103                buckets,
1104            )
1105        };
1106
1107        let kv_log_store_rewind_delay = register_guarded_histogram_vec_with_registry!(
1108            kv_log_store_rewind_delay_opts,
1109            &["actor_id", "connector", "sink_id", "sink_name"],
1110            registry
1111        )
1112        .unwrap();
1113
1114        let kv_log_store_buffer_unconsumed_item_count =
1115            register_guarded_int_gauge_vec_with_registry!(
1116                "kv_log_store_buffer_unconsumed_item_count",
1117                "Number of Unconsumed Item in buffer",
1118                &["actor_id", "connector", "sink_id", "sink_name"],
1119                registry
1120            )
1121            .unwrap();
1122
1123        let kv_log_store_buffer_unconsumed_row_count =
1124            register_guarded_int_gauge_vec_with_registry!(
1125                "kv_log_store_buffer_unconsumed_row_count",
1126                "Number of Unconsumed Row in buffer",
1127                &["actor_id", "connector", "sink_id", "sink_name"],
1128                registry
1129            )
1130            .unwrap();
1131
1132        let kv_log_store_buffer_unconsumed_epoch_count =
1133            register_guarded_int_gauge_vec_with_registry!(
1134                "kv_log_store_buffer_unconsumed_epoch_count",
1135                "Number of Unconsumed Epoch in buffer",
1136                &["actor_id", "connector", "sink_id", "sink_name"],
1137                registry
1138            )
1139            .unwrap();
1140
1141        let kv_log_store_buffer_unconsumed_min_epoch =
1142            register_guarded_int_gauge_vec_with_registry!(
1143                "kv_log_store_buffer_unconsumed_min_epoch",
1144                "Number of Unconsumed Epoch in buffer",
1145                &["actor_id", "connector", "sink_id", "sink_name"],
1146                registry
1147            )
1148            .unwrap();
1149
1150        let crossdb_last_consumed_min_epoch = register_guarded_int_gauge_vec_with_registry!(
1151            "crossdb_last_consumed_min_epoch",
1152            "Last consumed min epoch for cross-database changelog stream scan",
1153            &["table_id", "actor_id", "fragment_id"],
1154            registry
1155        )
1156        .unwrap();
1157
1158        let kv_log_store_buffer_memory_bytes =
1159            register_guarded_int_gauge_vec_with_registry!(
1160                "kv_log_store_buffer_memory_bytes",
1161                "Estimated heap bytes used by kv log store buffer (unconsumed + consumed but not truncated)",
1162                &["actor_id", "connector", "sink_id", "sink_name"],
1163                registry
1164            )
1165            .unwrap();
1166
1167        let lru_runtime_loop_count = register_int_counter_with_registry!(
1168            "lru_runtime_loop_count",
1169            "The counts of the eviction loop in LRU manager per second",
1170            registry
1171        )
1172        .unwrap();
1173
1174        let lru_latest_sequence = register_int_gauge_with_registry!(
1175            "lru_latest_sequence",
1176            "Current LRU global sequence",
1177            registry,
1178        )
1179        .unwrap();
1180
1181        let lru_watermark_sequence = register_int_gauge_with_registry!(
1182            "lru_watermark_sequence",
1183            "Current LRU watermark sequence",
1184            registry,
1185        )
1186        .unwrap();
1187
1188        let lru_eviction_policy = register_int_gauge_with_registry!(
1189            "lru_eviction_policy",
1190            "Current LRU eviction policy",
1191            registry,
1192        )
1193        .unwrap();
1194
1195        let jemalloc_allocated_bytes = register_int_gauge_with_registry!(
1196            "jemalloc_allocated_bytes",
1197            "The allocated memory jemalloc, got from jemalloc_ctl",
1198            registry
1199        )
1200        .unwrap();
1201
1202        let jemalloc_active_bytes = register_int_gauge_with_registry!(
1203            "jemalloc_active_bytes",
1204            "The active memory jemalloc, got from jemalloc_ctl",
1205            registry
1206        )
1207        .unwrap();
1208
1209        let jemalloc_resident_bytes = register_int_gauge_with_registry!(
1210            "jemalloc_resident_bytes",
1211            "The active memory jemalloc, got from jemalloc_ctl",
1212            registry
1213        )
1214        .unwrap();
1215
1216        let jemalloc_metadata_bytes = register_int_gauge_with_registry!(
1217            "jemalloc_metadata_bytes",
1218            "The active memory jemalloc, got from jemalloc_ctl",
1219            registry
1220        )
1221        .unwrap();
1222
1223        let jvm_allocated_bytes = register_int_gauge_with_registry!(
1224            "jvm_allocated_bytes",
1225            "The allocated jvm memory",
1226            registry
1227        )
1228        .unwrap();
1229
1230        let jvm_active_bytes = register_int_gauge_with_registry!(
1231            "jvm_active_bytes",
1232            "The active jvm memory",
1233            registry
1234        )
1235        .unwrap();
1236
1237        let materialize_cache_hit_count = register_guarded_int_counter_vec_with_registry!(
1238            "stream_materialize_cache_hit_count",
1239            "Materialize executor cache hit count",
1240            &["actor_id", "table_id", "fragment_id"],
1241            registry
1242        )
1243        .unwrap()
1244        .relabel_debug_1(level);
1245
1246        let materialize_data_exist_count = register_guarded_int_counter_vec_with_registry!(
1247            "stream_materialize_data_exist_count",
1248            "Materialize executor data exist count",
1249            &["actor_id", "table_id", "fragment_id"],
1250            registry
1251        )
1252        .unwrap()
1253        .relabel_debug_1(level);
1254
1255        let materialize_cache_total_count = register_guarded_int_counter_vec_with_registry!(
1256            "stream_materialize_cache_total_count",
1257            "Materialize executor cache total operation",
1258            &["actor_id", "table_id", "fragment_id"],
1259            registry
1260        )
1261        .unwrap()
1262        .relabel_debug_1(level);
1263
1264        let stream_memory_usage = register_guarded_int_gauge_vec_with_registry!(
1265            "stream_memory_usage",
1266            "Memory usage for stream executors",
1267            &["actor_id", "table_id", "desc"],
1268            registry
1269        )
1270        .unwrap()
1271        .relabel_debug_1(level);
1272
1273        let gap_fill_generated_rows_count = register_guarded_int_counter_vec_with_registry!(
1274            "gap_fill_generated_rows_count",
1275            "Total number of rows generated by gap fill executor",
1276            &["actor_id", "fragment_id"],
1277            registry
1278        )
1279        .unwrap()
1280        .relabel_debug_1(level);
1281
1282        let state_table_iter_count = register_guarded_int_counter_vec_with_registry!(
1283            "state_table_iter_count",
1284            "Total number of state table iter operations",
1285            &["actor_id", "fragment_id", "table_id"],
1286            registry
1287        )
1288        .unwrap()
1289        .relabel_debug_1(level);
1290
1291        let state_table_get_count = register_guarded_int_counter_vec_with_registry!(
1292            "state_table_get_count",
1293            "Total number of state table get operations",
1294            &["actor_id", "fragment_id", "table_id"],
1295            registry
1296        )
1297        .unwrap()
1298        .relabel_debug_1(level);
1299
1300        let state_table_iter_vnode_pruned_count = register_guarded_int_counter_vec_with_registry!(
1301            "state_table_iter_vnode_pruned_count",
1302            "Total number of state table iter operations pruned by vnode statistics",
1303            &["actor_id", "fragment_id", "table_id"],
1304            registry
1305        )
1306        .unwrap()
1307        .relabel_debug_1(level);
1308
1309        let state_table_get_vnode_pruned_count = register_guarded_int_counter_vec_with_registry!(
1310            "state_table_get_vnode_pruned_count",
1311            "Total number of state table get operations pruned by vnode statistics",
1312            &["actor_id", "fragment_id", "table_id"],
1313            registry
1314        )
1315        .unwrap()
1316        .relabel_debug_1(level);
1317
1318        Self {
1319            level,
1320            executor_row_count,
1321            mem_stream_node_output_row_count: stream_node_output_row_count,
1322            mem_stream_node_output_blocking_duration_ns: stream_node_output_blocking_duration_ns,
1323            actor_scheduled_duration,
1324            actor_scheduled_cnt,
1325            actor_poll_duration,
1326            actor_poll_cnt,
1327            actor_idle_duration,
1328            actor_idle_cnt,
1329            actor_count,
1330            actor_in_record_cnt,
1331            actor_out_record_cnt,
1332            fragment_channel_buffered_bytes,
1333            actor_current_epoch,
1334            project_expr_inflight_window_size,
1335            source_output_row_count,
1336            source_split_change_count,
1337            source_backfill_row_count,
1338            sink_input_row_count,
1339            sink_input_bytes,
1340            sink_chunk_buffer_size,
1341            exchange_frag_recv_size,
1342            merge_barrier_align_duration,
1343            actor_output_buffer_blocking_duration_ns,
1344            actor_input_buffer_blocking_duration_ns,
1345            join_lookup_miss_count,
1346            join_lookup_total_count,
1347            join_insert_cache_miss_count,
1348            join_actor_input_waiting_duration_ns,
1349            join_match_duration_ns,
1350            join_cached_entry_count,
1351            join_matched_join_keys,
1352            barrier_align_duration,
1353            agg_lookup_miss_count,
1354            agg_total_lookup_count,
1355            agg_cached_entry_count,
1356            agg_chunk_lookup_miss_count,
1357            agg_chunk_total_lookup_count,
1358            agg_dirty_groups_count,
1359            agg_dirty_groups_heap_size,
1360            agg_distinct_cache_miss_count,
1361            agg_distinct_total_cache_count,
1362            agg_distinct_cached_entry_count,
1363            agg_state_cache_lookup_count,
1364            agg_state_cache_miss_count,
1365            group_top_n_cache_miss_count,
1366            group_top_n_total_query_cache_count,
1367            group_top_n_cached_entry_count,
1368            group_top_n_appendonly_cache_miss_count,
1369            group_top_n_appendonly_total_query_cache_count,
1370            group_top_n_appendonly_cached_entry_count,
1371            lookup_cache_miss_count,
1372            lookup_total_query_cache_count,
1373            lookup_cached_entry_count,
1374            temporal_join_cache_miss_count,
1375            temporal_join_total_query_cache_count,
1376            temporal_join_cached_entry_count,
1377            backfill_snapshot_read_row_count,
1378            backfill_upstream_output_row_count,
1379            cdc_backfill_snapshot_read_row_count,
1380            cdc_backfill_upstream_output_row_count,
1381            snapshot_backfill_consume_row_count,
1382            over_window_cached_entry_count,
1383            over_window_cache_lookup_count,
1384            over_window_cache_miss_count,
1385            over_window_range_cache_entry_count,
1386            over_window_range_cache_lookup_count,
1387            over_window_range_cache_left_miss_count,
1388            over_window_range_cache_right_miss_count,
1389            over_window_accessed_entry_count,
1390            over_window_compute_count,
1391            over_window_same_output_count,
1392            barrier_inflight_latency,
1393            barrier_sync_latency,
1394            barrier_batch_size,
1395            barrier_manager_progress,
1396            kv_log_store_storage_write_count,
1397            kv_log_store_storage_write_size,
1398            kv_log_store_rewind_count,
1399            kv_log_store_rewind_delay,
1400            kv_log_store_storage_read_count,
1401            kv_log_store_storage_read_size,
1402            kv_log_store_buffer_unconsumed_item_count,
1403            kv_log_store_buffer_unconsumed_row_count,
1404            kv_log_store_buffer_unconsumed_epoch_count,
1405            kv_log_store_buffer_unconsumed_min_epoch,
1406            kv_log_store_buffer_memory_bytes,
1407            crossdb_last_consumed_min_epoch,
1408            sync_kv_log_store_read_count,
1409            sync_kv_log_store_read_size,
1410            sync_kv_log_store_write_pause_duration_ns,
1411            sync_kv_log_store_state,
1412            sync_kv_log_store_wait_next_poll_ns,
1413            sync_kv_log_store_storage_write_count,
1414            sync_kv_log_store_storage_write_size,
1415            sync_kv_log_store_buffer_unconsumed_item_count,
1416            sync_kv_log_store_buffer_unconsumed_row_count,
1417            sync_kv_log_store_buffer_unconsumed_epoch_count,
1418            sync_kv_log_store_buffer_unconsumed_min_epoch,
1419            sync_kv_log_store_buffer_memory_bytes,
1420            lru_runtime_loop_count,
1421            lru_latest_sequence,
1422            lru_watermark_sequence,
1423            lru_eviction_policy,
1424            jemalloc_allocated_bytes,
1425            jemalloc_active_bytes,
1426            jemalloc_resident_bytes,
1427            jemalloc_metadata_bytes,
1428            jvm_allocated_bytes,
1429            jvm_active_bytes,
1430            stream_memory_usage,
1431            materialize_cache_hit_count,
1432            materialize_data_exist_count,
1433            materialize_cache_total_count,
1434            materialize_input_row_count,
1435            materialize_current_epoch,
1436            pg_cdc_state_table_lsn,
1437            pg_cdc_jni_commit_offset_lsn,
1438            mysql_cdc_state_binlog_file_seq,
1439            mysql_cdc_state_binlog_position,
1440            sqlserver_cdc_state_change_lsn,
1441            sqlserver_cdc_state_commit_lsn,
1442            sqlserver_cdc_jni_commit_offset_lsn,
1443            gap_fill_generated_rows_count,
1444            state_table_iter_count,
1445            state_table_get_count,
1446            state_table_iter_vnode_pruned_count,
1447            state_table_get_vnode_pruned_count,
1448        }
1449    }
1450
1451    /// Create a new `StreamingMetrics` instance used in tests or other places.
1452    pub fn unused() -> Self {
1453        global_streaming_metrics(MetricLevel::Disabled)
1454    }
1455
1456    pub fn new_actor_metrics(&self, actor_id: ActorId, fragment_id: FragmentId) -> ActorMetrics {
1457        let label_list: &[&str; 2] = &[&actor_id.to_string(), &fragment_id.to_string()];
1458        let actor_scheduled_duration = self
1459            .actor_scheduled_duration
1460            .with_guarded_label_values(label_list);
1461        let actor_scheduled_cnt = self
1462            .actor_scheduled_cnt
1463            .with_guarded_label_values(label_list);
1464        let actor_poll_duration = self
1465            .actor_poll_duration
1466            .with_guarded_label_values(label_list);
1467        let actor_poll_cnt = self.actor_poll_cnt.with_guarded_label_values(label_list);
1468        let actor_idle_duration = self
1469            .actor_idle_duration
1470            .with_guarded_label_values(label_list);
1471        let actor_idle_cnt = self.actor_idle_cnt.with_guarded_label_values(label_list);
1472        ActorMetrics {
1473            actor_scheduled_duration,
1474            actor_scheduled_cnt,
1475            actor_poll_duration,
1476            actor_poll_cnt,
1477            actor_idle_duration,
1478            actor_idle_cnt,
1479        }
1480    }
1481
1482    pub(crate) fn new_actor_input_metrics(
1483        &self,
1484        actor_id: ActorId,
1485        fragment_id: FragmentId,
1486        upstream_fragment_id: FragmentId,
1487    ) -> ActorInputMetrics {
1488        let actor_id_str = actor_id.to_string();
1489        let fragment_id_str = fragment_id.to_string();
1490        let upstream_fragment_id_str = upstream_fragment_id.to_string();
1491        ActorInputMetrics {
1492            actor_in_record_cnt: self.actor_in_record_cnt.with_guarded_label_values(&[
1493                &actor_id_str,
1494                &fragment_id_str,
1495                &upstream_fragment_id_str,
1496            ]),
1497            actor_input_buffer_blocking_duration_ns: self
1498                .actor_input_buffer_blocking_duration_ns
1499                .with_guarded_label_values(&[
1500                    &actor_id_str,
1501                    &fragment_id_str,
1502                    &upstream_fragment_id_str,
1503                ]),
1504        }
1505    }
1506
1507    pub fn new_sink_exec_metrics(
1508        &self,
1509        id: SinkId,
1510        actor_id: ActorId,
1511        fragment_id: FragmentId,
1512    ) -> SinkExecutorMetrics {
1513        let label_list: &[&str; 3] = &[
1514            &id.to_string(),
1515            &actor_id.to_string(),
1516            &fragment_id.to_string(),
1517        ];
1518        SinkExecutorMetrics {
1519            sink_input_row_count: self
1520                .sink_input_row_count
1521                .with_guarded_label_values(label_list),
1522            sink_input_bytes: self.sink_input_bytes.with_guarded_label_values(label_list),
1523            sink_chunk_buffer_size: self
1524                .sink_chunk_buffer_size
1525                .with_guarded_label_values(label_list),
1526        }
1527    }
1528
1529    pub fn new_group_top_n_metrics(
1530        &self,
1531        table_id: TableId,
1532        actor_id: ActorId,
1533        fragment_id: FragmentId,
1534    ) -> GroupTopNMetrics {
1535        let label_list: &[&str; 3] = &[
1536            &table_id.to_string(),
1537            &actor_id.to_string(),
1538            &fragment_id.to_string(),
1539        ];
1540
1541        GroupTopNMetrics {
1542            group_top_n_cache_miss_count: self
1543                .group_top_n_cache_miss_count
1544                .with_guarded_label_values(label_list),
1545            group_top_n_total_query_cache_count: self
1546                .group_top_n_total_query_cache_count
1547                .with_guarded_label_values(label_list),
1548            group_top_n_cached_entry_count: self
1549                .group_top_n_cached_entry_count
1550                .with_guarded_label_values(label_list),
1551        }
1552    }
1553
1554    pub fn new_append_only_group_top_n_metrics(
1555        &self,
1556        table_id: TableId,
1557        actor_id: ActorId,
1558        fragment_id: FragmentId,
1559    ) -> GroupTopNMetrics {
1560        let label_list: &[&str; 3] = &[
1561            &table_id.to_string(),
1562            &actor_id.to_string(),
1563            &fragment_id.to_string(),
1564        ];
1565
1566        GroupTopNMetrics {
1567            group_top_n_cache_miss_count: self
1568                .group_top_n_appendonly_cache_miss_count
1569                .with_guarded_label_values(label_list),
1570            group_top_n_total_query_cache_count: self
1571                .group_top_n_appendonly_total_query_cache_count
1572                .with_guarded_label_values(label_list),
1573            group_top_n_cached_entry_count: self
1574                .group_top_n_appendonly_cached_entry_count
1575                .with_guarded_label_values(label_list),
1576        }
1577    }
1578
1579    pub fn new_lookup_executor_metrics(
1580        &self,
1581        table_id: TableId,
1582        actor_id: ActorId,
1583        fragment_id: FragmentId,
1584    ) -> LookupExecutorMetrics {
1585        let label_list: &[&str; 3] = &[
1586            &table_id.to_string(),
1587            &actor_id.to_string(),
1588            &fragment_id.to_string(),
1589        ];
1590
1591        LookupExecutorMetrics {
1592            lookup_cache_miss_count: self
1593                .lookup_cache_miss_count
1594                .with_guarded_label_values(label_list),
1595            lookup_total_query_cache_count: self
1596                .lookup_total_query_cache_count
1597                .with_guarded_label_values(label_list),
1598            lookup_cached_entry_count: self
1599                .lookup_cached_entry_count
1600                .with_guarded_label_values(label_list),
1601        }
1602    }
1603
1604    pub fn new_hash_agg_metrics(
1605        &self,
1606        table_id: TableId,
1607        actor_id: ActorId,
1608        fragment_id: FragmentId,
1609    ) -> HashAggMetrics {
1610        let label_list: &[&str; 3] = &[
1611            &table_id.to_string(),
1612            &actor_id.to_string(),
1613            &fragment_id.to_string(),
1614        ];
1615        HashAggMetrics {
1616            agg_lookup_miss_count: self
1617                .agg_lookup_miss_count
1618                .with_guarded_label_values(label_list),
1619            agg_total_lookup_count: self
1620                .agg_total_lookup_count
1621                .with_guarded_label_values(label_list),
1622            agg_cached_entry_count: self
1623                .agg_cached_entry_count
1624                .with_guarded_label_values(label_list),
1625            agg_chunk_lookup_miss_count: self
1626                .agg_chunk_lookup_miss_count
1627                .with_guarded_label_values(label_list),
1628            agg_chunk_total_lookup_count: self
1629                .agg_chunk_total_lookup_count
1630                .with_guarded_label_values(label_list),
1631            agg_dirty_groups_count: self
1632                .agg_dirty_groups_count
1633                .with_guarded_label_values(label_list),
1634            agg_dirty_groups_heap_size: self
1635                .agg_dirty_groups_heap_size
1636                .with_guarded_label_values(label_list),
1637            agg_state_cache_lookup_count: self
1638                .agg_state_cache_lookup_count
1639                .with_guarded_label_values(label_list),
1640            agg_state_cache_miss_count: self
1641                .agg_state_cache_miss_count
1642                .with_guarded_label_values(label_list),
1643        }
1644    }
1645
1646    pub fn new_agg_distinct_dedup_metrics(
1647        &self,
1648        table_id: TableId,
1649        actor_id: ActorId,
1650        fragment_id: FragmentId,
1651    ) -> AggDistinctDedupMetrics {
1652        let label_list: &[&str; 3] = &[
1653            &table_id.to_string(),
1654            &actor_id.to_string(),
1655            &fragment_id.to_string(),
1656        ];
1657        AggDistinctDedupMetrics {
1658            agg_distinct_cache_miss_count: self
1659                .agg_distinct_cache_miss_count
1660                .with_guarded_label_values(label_list),
1661            agg_distinct_total_cache_count: self
1662                .agg_distinct_total_cache_count
1663                .with_guarded_label_values(label_list),
1664            agg_distinct_cached_entry_count: self
1665                .agg_distinct_cached_entry_count
1666                .with_guarded_label_values(label_list),
1667        }
1668    }
1669
1670    pub fn new_temporal_join_metrics(
1671        &self,
1672        table_id: TableId,
1673        actor_id: ActorId,
1674        fragment_id: FragmentId,
1675    ) -> TemporalJoinMetrics {
1676        let label_list: &[&str; 3] = &[
1677            &table_id.to_string(),
1678            &actor_id.to_string(),
1679            &fragment_id.to_string(),
1680        ];
1681        TemporalJoinMetrics {
1682            temporal_join_cache_miss_count: self
1683                .temporal_join_cache_miss_count
1684                .with_guarded_label_values(label_list),
1685            temporal_join_total_query_cache_count: self
1686                .temporal_join_total_query_cache_count
1687                .with_guarded_label_values(label_list),
1688            temporal_join_cached_entry_count: self
1689                .temporal_join_cached_entry_count
1690                .with_guarded_label_values(label_list),
1691        }
1692    }
1693
1694    pub fn new_backfill_metrics(&self, table_id: TableId, actor_id: ActorId) -> BackfillMetrics {
1695        let label_list: &[&str; 2] = &[&table_id.to_string(), &actor_id.to_string()];
1696        BackfillMetrics {
1697            backfill_snapshot_read_row_count: self
1698                .backfill_snapshot_read_row_count
1699                .with_guarded_label_values(label_list),
1700            backfill_upstream_output_row_count: self
1701                .backfill_upstream_output_row_count
1702                .with_guarded_label_values(label_list),
1703        }
1704    }
1705
1706    pub fn new_cdc_backfill_metrics(
1707        &self,
1708        table_id: TableId,
1709        actor_id: ActorId,
1710    ) -> CdcBackfillMetrics {
1711        let label_list: &[&str; 2] = &[&table_id.to_string(), &actor_id.to_string()];
1712        CdcBackfillMetrics {
1713            cdc_backfill_snapshot_read_row_count: self
1714                .cdc_backfill_snapshot_read_row_count
1715                .with_guarded_label_values(label_list),
1716            cdc_backfill_upstream_output_row_count: self
1717                .cdc_backfill_upstream_output_row_count
1718                .with_guarded_label_values(label_list),
1719        }
1720    }
1721
1722    pub fn new_over_window_metrics(
1723        &self,
1724        table_id: TableId,
1725        actor_id: ActorId,
1726        fragment_id: FragmentId,
1727    ) -> OverWindowMetrics {
1728        let label_list: &[&str; 3] = &[
1729            &table_id.to_string(),
1730            &actor_id.to_string(),
1731            &fragment_id.to_string(),
1732        ];
1733        OverWindowMetrics {
1734            over_window_cached_entry_count: self
1735                .over_window_cached_entry_count
1736                .with_guarded_label_values(label_list),
1737            over_window_cache_lookup_count: self
1738                .over_window_cache_lookup_count
1739                .with_guarded_label_values(label_list),
1740            over_window_cache_miss_count: self
1741                .over_window_cache_miss_count
1742                .with_guarded_label_values(label_list),
1743            over_window_range_cache_entry_count: self
1744                .over_window_range_cache_entry_count
1745                .with_guarded_label_values(label_list),
1746            over_window_range_cache_lookup_count: self
1747                .over_window_range_cache_lookup_count
1748                .with_guarded_label_values(label_list),
1749            over_window_range_cache_left_miss_count: self
1750                .over_window_range_cache_left_miss_count
1751                .with_guarded_label_values(label_list),
1752            over_window_range_cache_right_miss_count: self
1753                .over_window_range_cache_right_miss_count
1754                .with_guarded_label_values(label_list),
1755            over_window_accessed_entry_count: self
1756                .over_window_accessed_entry_count
1757                .with_guarded_label_values(label_list),
1758            over_window_compute_count: self
1759                .over_window_compute_count
1760                .with_guarded_label_values(label_list),
1761            over_window_same_output_count: self
1762                .over_window_same_output_count
1763                .with_guarded_label_values(label_list),
1764        }
1765    }
1766
1767    pub fn new_materialize_cache_metrics(
1768        &self,
1769        table_id: TableId,
1770        actor_id: ActorId,
1771        fragment_id: FragmentId,
1772    ) -> MaterializeCacheMetrics {
1773        let label_list: &[&str; 3] = &[
1774            &actor_id.to_string(),
1775            &table_id.to_string(),
1776            &fragment_id.to_string(),
1777        ];
1778        MaterializeCacheMetrics {
1779            materialize_cache_hit_count: self
1780                .materialize_cache_hit_count
1781                .with_guarded_label_values(label_list),
1782            materialize_data_exist_count: self
1783                .materialize_data_exist_count
1784                .with_guarded_label_values(label_list),
1785            materialize_cache_total_count: self
1786                .materialize_cache_total_count
1787                .with_guarded_label_values(label_list),
1788        }
1789    }
1790
1791    pub fn new_materialize_metrics(
1792        &self,
1793        table_id: TableId,
1794        actor_id: ActorId,
1795        fragment_id: FragmentId,
1796    ) -> MaterializeMetrics {
1797        let label_list: &[&str; 3] = &[
1798            &actor_id.to_string(),
1799            &table_id.to_string(),
1800            &fragment_id.to_string(),
1801        ];
1802        MaterializeMetrics {
1803            materialize_input_row_count: self
1804                .materialize_input_row_count
1805                .with_guarded_label_values(label_list),
1806            materialize_current_epoch: self
1807                .materialize_current_epoch
1808                .with_guarded_label_values(label_list),
1809        }
1810    }
1811
1812    pub fn new_state_table_metrics(
1813        &self,
1814        table_id: TableId,
1815        actor_id: ActorId,
1816        fragment_id: FragmentId,
1817    ) -> StateTableMetrics {
1818        let label_list: &[&str; 3] = &[
1819            &actor_id.to_string(),
1820            &fragment_id.to_string(),
1821            &table_id.to_string(),
1822        ];
1823        StateTableMetrics {
1824            iter_count: self
1825                .state_table_iter_count
1826                .with_guarded_label_values(label_list),
1827            get_count: self
1828                .state_table_get_count
1829                .with_guarded_label_values(label_list),
1830            iter_vnode_pruned_count: self
1831                .state_table_iter_vnode_pruned_count
1832                .with_guarded_label_values(label_list),
1833            get_vnode_pruned_count: self
1834                .state_table_get_vnode_pruned_count
1835                .with_guarded_label_values(label_list),
1836        }
1837    }
1838}
1839
1840pub(crate) struct ActorInputMetrics {
1841    pub(crate) actor_in_record_cnt: LabelGuardedIntCounter,
1842    pub(crate) actor_input_buffer_blocking_duration_ns: LabelGuardedIntCounter,
1843}
1844
1845/// Tokio metrics for actors
1846pub struct ActorMetrics {
1847    pub actor_scheduled_duration: LabelGuardedIntCounter,
1848    pub actor_scheduled_cnt: LabelGuardedIntCounter,
1849    pub actor_poll_duration: LabelGuardedIntCounter,
1850    pub actor_poll_cnt: LabelGuardedIntCounter,
1851    pub actor_idle_duration: LabelGuardedIntCounter,
1852    pub actor_idle_cnt: LabelGuardedIntCounter,
1853}
1854
1855pub struct SinkExecutorMetrics {
1856    pub sink_input_row_count: LabelGuardedIntCounter,
1857    pub sink_input_bytes: LabelGuardedIntCounter,
1858    pub sink_chunk_buffer_size: LabelGuardedIntGauge,
1859}
1860
1861pub struct MaterializeCacheMetrics {
1862    pub materialize_cache_hit_count: LabelGuardedIntCounter,
1863    pub materialize_data_exist_count: LabelGuardedIntCounter,
1864    pub materialize_cache_total_count: LabelGuardedIntCounter,
1865}
1866
1867pub struct MaterializeMetrics {
1868    pub materialize_input_row_count: LabelGuardedIntCounter,
1869    pub materialize_current_epoch: LabelGuardedIntGauge,
1870}
1871
1872pub struct GroupTopNMetrics {
1873    pub group_top_n_cache_miss_count: LabelGuardedIntCounter,
1874    pub group_top_n_total_query_cache_count: LabelGuardedIntCounter,
1875    pub group_top_n_cached_entry_count: LabelGuardedIntGauge,
1876}
1877
1878pub struct LookupExecutorMetrics {
1879    pub lookup_cache_miss_count: LabelGuardedIntCounter,
1880    pub lookup_total_query_cache_count: LabelGuardedIntCounter,
1881    pub lookup_cached_entry_count: LabelGuardedIntGauge,
1882}
1883
1884pub struct HashAggMetrics {
1885    pub agg_lookup_miss_count: LabelGuardedIntCounter,
1886    pub agg_total_lookup_count: LabelGuardedIntCounter,
1887    pub agg_cached_entry_count: LabelGuardedIntGauge,
1888    pub agg_chunk_lookup_miss_count: LabelGuardedIntCounter,
1889    pub agg_chunk_total_lookup_count: LabelGuardedIntCounter,
1890    pub agg_dirty_groups_count: LabelGuardedIntGauge,
1891    pub agg_dirty_groups_heap_size: LabelGuardedIntGauge,
1892    pub agg_state_cache_lookup_count: LabelGuardedIntCounter,
1893    pub agg_state_cache_miss_count: LabelGuardedIntCounter,
1894}
1895
1896pub struct AggDistinctDedupMetrics {
1897    pub agg_distinct_cache_miss_count: LabelGuardedIntCounter,
1898    pub agg_distinct_total_cache_count: LabelGuardedIntCounter,
1899    pub agg_distinct_cached_entry_count: LabelGuardedIntGauge,
1900}
1901
1902pub struct TemporalJoinMetrics {
1903    pub temporal_join_cache_miss_count: LabelGuardedIntCounter,
1904    pub temporal_join_total_query_cache_count: LabelGuardedIntCounter,
1905    pub temporal_join_cached_entry_count: LabelGuardedIntGauge,
1906}
1907
1908pub struct BackfillMetrics {
1909    pub backfill_snapshot_read_row_count: LabelGuardedIntCounter,
1910    pub backfill_upstream_output_row_count: LabelGuardedIntCounter,
1911}
1912
1913#[derive(Clone)]
1914pub struct CdcBackfillMetrics {
1915    pub cdc_backfill_snapshot_read_row_count: LabelGuardedIntCounter,
1916    pub cdc_backfill_upstream_output_row_count: LabelGuardedIntCounter,
1917}
1918
1919pub struct OverWindowMetrics {
1920    pub over_window_cached_entry_count: LabelGuardedIntGauge,
1921    pub over_window_cache_lookup_count: LabelGuardedIntCounter,
1922    pub over_window_cache_miss_count: LabelGuardedIntCounter,
1923    pub over_window_range_cache_entry_count: LabelGuardedIntGauge,
1924    pub over_window_range_cache_lookup_count: LabelGuardedIntCounter,
1925    pub over_window_range_cache_left_miss_count: LabelGuardedIntCounter,
1926    pub over_window_range_cache_right_miss_count: LabelGuardedIntCounter,
1927    pub over_window_accessed_entry_count: LabelGuardedIntCounter,
1928    pub over_window_compute_count: LabelGuardedIntCounter,
1929    pub over_window_same_output_count: LabelGuardedIntCounter,
1930}
1931
1932#[derive(Clone)]
1933pub struct StateTableMetrics {
1934    pub iter_count: LabelGuardedIntCounter,
1935    pub get_count: LabelGuardedIntCounter,
1936    pub iter_vnode_pruned_count: LabelGuardedIntCounter,
1937    pub get_vnode_pruned_count: LabelGuardedIntCounter,
1938}