Repository: apache/kafka
File: storage/api/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteStorageMetrics.java (Java)

Code before:
    public static final MetricName FAILED_REMOTE_COPY_PER_SEC_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", FAILED_REMOTE_COPY_PER_SEC);
    public static final MetricName REMOTE_LOG_METADATA_COUNT_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_LOG_METADATA_COUNT);
    public static final MetricName REMOTE_LOG_SIZE_BYTES_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_LOG_SIZE_BYTES);
    public static final MetricName REMOTE_LOG_SIZE_COMPUTATION_TIME_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_LOG_SIZE_COMPUTATION_TIME);
    public static final MetricName FAILED_REMOTE_DELETE_PER_SEC_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", FAILED_REMOTE_DELETE_PER_SEC);
    public static final MetricName FAILED_BUILD_REMOTE_LOG_AUX_STATE_PER_SEC_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", FAILED_BUILD_REMOTE_LOG_AUX_STATE_PER_SEC);
    public static final MetricName REMOTE_COPY_LAG_BYTES_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_COPY_LAG_BYTES);
    public static final MetricName REMOTE_COPY_LAG_SEGMENTS_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_COPY_LAG_SEGMENTS);
    public static final MetricName REMOTE_DELETE_LAG_BYTES_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_DELETE_LAG_BYTES);
    public static final MetricName REMOTE_DELETE_LAG_SEGMENTS_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_DELETE_LAG_SEGMENTS);
    public static final MetricName REMOTE_LOG_MANAGER_TASKS_AVG_IDLE_PERCENT_METRIC = getMetricName(
            "kafka.log.remote", "RemoteLogManager", REMOTE_LOG_MANAGER_TASKS_AVG_IDLE_PERCENT);
    public static final MetricName REMOTE_LOG_READER_TASK_QUEUE_SIZE_METRIC = getMetricName(
            "org.apache.kafka.storage.internals.log", "RemoteStorageThreadPool", REMOTE_LOG_READER_TASK_QUEUE_SIZE);
    public static final MetricName REMOTE_LOG_READER_AVG_IDLE_PERCENT_METRIC = getMetricName(
            "org.apache.kafka.storage.internals.log", "RemoteStorageThreadPool", REMOTE_LOG_READER_AVG_IDLE_PERCENT);
    /**
     * Since `REMOTE_LOG_READER_TASK_QUEUE_SIZE_METRIC` and `REMOTE_LOG_READER_AVG_IDLE_PERCENT_METRIC` 
     * are part of the public API, we add new metrics with the same names under the `kafka.log.remote` group 
     * and prefix them with `BRIDGE_` to avoid conflicts with the existing `MetricName` values.
     * <p>
     * The new metrics are marked as deprecated. In Kafka 5.0, we will remove the deprecated metrics 
     * and use the `kafka.log.remote` group name as the standard going forward.
     */
    @Deprecated(since = "4.2")
    public static final MetricName BRIDGE_REMOTE_LOG_READER_TASK_QUEUE_SIZE_METRIC = getMetricName(
            "kafka.log.remote", "RemoteStorageThreadPool", REMOTE_LOG_READER_TASK_QUEUE_SIZE);
    @Deprecated(since = "4.2")
    public static final MetricName BRIDGE_REMOTE_LOG_READER_AVG_IDLE_PERCENT_METRIC = getMetricName(
            "kafka.log.remote", "RemoteStorageThreadPool", REMOTE_LOG_READER_AVG_IDLE_PERCENT);
    public static final MetricName REMOTE_LOG_READER_FETCH_RATE_AND_TIME_METRIC = getMetricName(
            "kafka.log.remote", "RemoteLogManager", REMOTE_LOG_READER_FETCH_RATE_AND_TIME_MS);

    public static Set<MetricName> allMetrics() {
        Set<MetricName> metrics = new HashSet<>();

        metrics.add(REMOTE_COPY_BYTES_PER_SEC_METRIC);
        metrics.add(REMOTE_FETCH_BYTES_PER_SEC_METRIC);
        metrics.add(REMOTE_FETCH_REQUESTS_PER_SEC_METRIC);
        metrics.add(REMOTE_COPY_REQUESTS_PER_SEC_METRIC);
        metrics.add(REMOTE_DELETE_REQUESTS_PER_SEC_METRIC);

Review comment (suggestion):
I brought this up in the mail channel (https://lists.apache.org/thread/cpsdrwcbdyys69ozr5kfbsycrkx8zkcn)

Code after:
    public static final MetricName FAILED_REMOTE_COPY_PER_SEC_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", FAILED_REMOTE_COPY_PER_SEC);
    public static final MetricName REMOTE_LOG_METADATA_COUNT_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_LOG_METADATA_COUNT);
    public static final MetricName REMOTE_LOG_SIZE_BYTES_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_LOG_SIZE_BYTES);
    public static final MetricName REMOTE_LOG_SIZE_COMPUTATION_TIME_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_LOG_SIZE_COMPUTATION_TIME);
    public static final MetricName FAILED_REMOTE_DELETE_PER_SEC_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", FAILED_REMOTE_DELETE_PER_SEC);
    public static final MetricName FAILED_BUILD_REMOTE_LOG_AUX_STATE_PER_SEC_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", FAILED_BUILD_REMOTE_LOG_AUX_STATE_PER_SEC);
    public static final MetricName REMOTE_COPY_LAG_BYTES_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_COPY_LAG_BYTES);
    public static final MetricName REMOTE_COPY_LAG_SEGMENTS_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_COPY_LAG_SEGMENTS);
    public static final MetricName REMOTE_DELETE_LAG_BYTES_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_DELETE_LAG_BYTES);
    public static final MetricName REMOTE_DELETE_LAG_SEGMENTS_METRIC = getMetricName(
            "kafka.server", "BrokerTopicMetrics", REMOTE_DELETE_LAG_SEGMENTS);
    public static final MetricName REMOTE_LOG_MANAGER_TASKS_AVG_IDLE_PERCENT_METRIC = getMetricName(
            "kafka.log.remote", "RemoteLogManager", REMOTE_LOG_MANAGER_TASKS_AVG_IDLE_PERCENT);
    @Deprecated(since = "4.2")
    public static final MetricName DEPRECATE_REMOTE_LOG_READER_TASK_QUEUE_SIZE_METRIC = getMetricName(
            "org.apache.kafka.storage.internals.log", "RemoteStorageThreadPool", REMOTE_LOG_READER_TASK_QUEUE_SIZE);
    @Deprecated(since = "4.2")
    public static final MetricName DEPRECATE_REMOTE_LOG_READER_AVG_IDLE_PERCENT_METRIC = getMetricName(
            "org.apache.kafka.storage.internals.log", "RemoteStorageThreadPool", REMOTE_LOG_READER_AVG_IDLE_PERCENT);
    public static final MetricName REMOTE_LOG_READER_TASK_QUEUE_SIZE_METRIC = getMetricName(
            "kafka.log.remote", "RemoteStorageThreadPool", REMOTE_LOG_READER_TASK_QUEUE_SIZE);
    public static final MetricName REMOTE_LOG_READER_AVG_IDLE_PERCENT_METRIC = getMetricName(
            "kafka.log.remote", "RemoteStorageThreadPool", REMOTE_LOG_READER_AVG_IDLE_PERCENT);
    public static final MetricName REMOTE_LOG_READER_FETCH_RATE_AND_TIME_METRIC = getMetricName(
            "kafka.log.remote", "RemoteLogManager", REMOTE_LOG_READER_FETCH_RATE_AND_TIME_MS);

    public static Set<MetricName> allMetrics() {
        Set<MetricName> metrics = new HashSet<>();

        metrics.add(REMOTE_COPY_BYTES_PER_SEC_METRIC);
        metrics.add(REMOTE_FETCH_BYTES_PER_SEC_METRIC);
        metrics.add(REMOTE_FETCH_REQUESTS_PER_SEC_METRIC);
        metrics.add(REMOTE_COPY_REQUESTS_PER_SEC_METRIC);
        metrics.add(REMOTE_DELETE_REQUESTS_PER_SEC_METRIC);
        metrics.add(BUILD_REMOTE_LOG_AUX_STATE_REQUESTS_PER_SEC_METRIC);
        metrics.add(FAILED_REMOTE_FETCH_PER_SEC_METRIC);
        metrics.add(FAILED_REMOTE_COPY_PER_SEC_METRIC);
        metrics.add(FAILED_REMOTE_DELETE_PER_SEC_METRIC);
        metrics.add(FAILED_BUILD_REMOTE_LOG_AUX_STATE_PER_SEC_METRIC);
        metrics.add(REMOTE_COPY_LAG_BYTES_METRIC);
        metrics.add(REMOTE_COPY_LAG_SEGMENTS_METRIC);
        metrics.add(REMOTE_DELETE_LAG_BYTES_METRIC);