Repository: risingwavelabs/risingwave
File: src/storage/src/monitor/hummock_state_store_metrics.rs (Rust)

Code before:
            &["table_id"],
            registry
        )
        .unwrap();

        let per_table_imm_size = RelabeledGuardedIntGaugeVec::with_metric_level(
            MetricLevel::Debug,
            per_table_imm_size,
            metric_level,
        );

        let per_table_imm_count = register_guarded_int_gauge_vec_with_registry!(
            "state_store_per_table_imm_count",
            "Total imm count per table",
            &["table_id"],
            registry
        )
        .unwrap();

        let per_table_imm_count = RelabeledGuardedIntGaugeVec::with_metric_level(
            MetricLevel::Debug,
            per_table_imm_count,
            metric_level,
        );

        let per_fragment_imm_size = register_guarded_int_gauge_vec_with_registry!(
            "state_store_per_fragment_imm_size",
            "Total imm size per fragment",
            &["fragment_id"],
            registry
        )
        .unwrap();

        let per_fragment_imm_size = RelabeledGuardedIntGaugeVec::with_metric_level(
            MetricLevel::Info,
            per_fragment_imm_size,
            metric_level,
        );

        let per_fragment_imm_count = register_guarded_int_gauge_vec_with_registry!(
            "state_store_per_fragment_imm_count",
            "Total imm count per fragment",
            &["fragment_id"],
            registry
        )
        .unwrap();

        let per_fragment_imm_count = RelabeledGuardedIntGaugeVec::with_metric_level(
            MetricLevel::Info,
            per_fragment_imm_count,
            metric_level,

Review comment (suggestion):
We can reuse the metrics per table_id. Currently the metrics are labeled with `[table_id]`, and the `table_id` will be relabeled to `""` by the RelabeledMetrics when the metrics level is not high enough. We can change to be labeled with `[fragment_id, table_id]`, and when metrics level is not high enough, we only relabel the `table_id`. We can do this by setting the prefix length of not-relabel to be 1

Code after:
        )
        .unwrap();

        let per_table_imm_size = RelabeledGuardedIntGaugeVec::with_metric_level_relabel_n(
            MetricLevel::Debug,
            per_table_imm_size,
            metric_level,
            1,
        );

        let per_table_imm_count = register_guarded_int_gauge_vec_with_registry!(
            "state_store_per_table_imm_count",
            "Total imm count per table",
            &["table_id"],
            registry
        )
        .unwrap();

        let per_table_imm_count = RelabeledGuardedIntGaugeVec::with_metric_level(
            MetricLevel::Debug,
            per_table_imm_count,
            metric_level,
        );

        let read_req_bloom_filter_positive_counts = register_guarded_int_counter_vec_with_registry!(
            "state_store_read_req_bloom_filter_positive_counts",
            "Total number of read request with at least one SST bloom filter check returns positive",
            &["table_id", "type"],
            registry
        )
        .unwrap();
        let read_req_bloom_filter_positive_counts =
            RelabeledGuardedIntCounterVec::with_metric_level_relabel_n(
                MetricLevel::Info,
                read_req_bloom_filter_positive_counts,
                metric_level,
                1,
            );

        let read_req_positive_but_non_exist_counts = register_guarded_int_counter_vec_with_registry!(
            "state_store_read_req_positive_but_non_exist_counts",
            "Total number of read request on non-existent key/prefix with at least one SST bloom filter check returns positive",
            &["table_id", "type"],
            registry
        )
        .unwrap();
        let read_req_positive_but_non_exist_counts =
            RelabeledGuardedIntCounterVec::with_metric_level(
                MetricLevel::Info,
                read_req_positive_but_non_exist_counts,
                metric_level,