Repository: apache/kafka
File: streams/src/main/java/org/apache/kafka/streams/processor/internals/metrics/ThreadMetrics.java (Java)

Code before:
    private static final String POLL_TOTAL_DESCRIPTION = TOTAL_DESCRIPTION + POLL_DESCRIPTION;
    private static final String POLL_RATE_DESCRIPTION = RATE_DESCRIPTION + POLL_DESCRIPTION;
    private static final String POLL_AVG_LATENCY_DESCRIPTION = "The average poll latency";
    private static final String POLL_MAX_LATENCY_DESCRIPTION = "The maximum poll latency";
    private static final String POLL_AVG_RECORDS_DESCRIPTION = "The average number of records polled from consumer within an iteration";
    private static final String POLL_MAX_RECORDS_DESCRIPTION = "The maximum number of records polled from consumer within an iteration";
    private static final String PROCESS_DESCRIPTION = "calls to process";
    private static final String PROCESS_TOTAL_DESCRIPTION = TOTAL_DESCRIPTION + PROCESS_DESCRIPTION;
    private static final String PROCESS_RATE_DESCRIPTION = RATE_DESCRIPTION + PROCESS_DESCRIPTION;
    private static final String PROCESS_AVG_LATENCY_DESCRIPTION = "The average process latency";
    private static final String PROCESS_MAX_LATENCY_DESCRIPTION = "The maximum process latency";
    private static final String PROCESS_AVG_RECORDS_DESCRIPTION = "The average number of records processed within an iteration";
    private static final String PROCESS_MAX_RECORDS_DESCRIPTION = "The maximum number of records processed within an iteration";
    private static final String PUNCTUATE_DESCRIPTION = "calls to punctuate";
    private static final String PUNCTUATE_TOTAL_DESCRIPTION = TOTAL_DESCRIPTION + PUNCTUATE_DESCRIPTION;
    private static final String PUNCTUATE_RATE_DESCRIPTION = RATE_DESCRIPTION + PUNCTUATE_DESCRIPTION;
    private static final String PUNCTUATE_AVG_LATENCY_DESCRIPTION = "The average punctuate latency";
    private static final String PUNCTUATE_MAX_LATENCY_DESCRIPTION = "The maximum punctuate latency";
    private static final String PROCESS_RATIO_DESCRIPTION =
        WINDOWED_RATIO_DESCRIPTION_PREFIX + "of the time this thread spent " +
            "processing active tasks to the total elapsed time in that window.";
    private static final String PUNCTUATE_RATIO_DESCRIPTION =
        WINDOWED_RATIO_DESCRIPTION_PREFIX + "of the time this thread spent " +
            "punctuating active tasks to the total elapsed time in that window.";
    private static final String POLL_RATIO_DESCRIPTION =
        WINDOWED_RATIO_DESCRIPTION_PREFIX + "of the time this thread spent " +
            "polling records from the consumer to the total elapsed time in that window.";
    private static final String COMMIT_RATIO_DESCRIPTION =
        WINDOWED_RATIO_DESCRIPTION_PREFIX + "of the time this thread spent " +
            "committing all tasks to the total elapsed time in that window.";
    private static final String BLOCKED_TIME_DESCRIPTION =
        "The total time the thread spent blocked on kafka in nanoseconds";
    private static final String THREAD_START_TIME_DESCRIPTION =
        "The time that the thread was started";
    private static final String THREAD_STATE_DESCRIPTION =
        "The current state of the thread";

    public static Sensor createTaskSensor(final String threadId,
                                          final StreamsMetricsImpl streamsMetrics) {
        return invocationRateAndCountSensor(
            threadId,
            CREATE_TASK,
            CREATE_TASK_RATE_DESCRIPTION,
            CREATE_TASK_TOTAL_DESCRIPTION,
            RecordingLevel.INFO,
            streamsMetrics
        );
    }

    public static Sensor closeTaskSensor(final String threadId,
                                         final StreamsMetricsImpl streamsMetrics) {

Review comment (refactor):
```suggestion
        WINDOWED_RATIO_DESCRIPTION_PREFIX +
```
dry

Code after:
    private static final String POLL_DESCRIPTION = "calls to poll";
    private static final String POLL_TOTAL_DESCRIPTION = TOTAL_DESCRIPTION + POLL_DESCRIPTION;
    private static final String POLL_RATE_DESCRIPTION = RATE_DESCRIPTION + POLL_DESCRIPTION;
    private static final String POLL_AVG_LATENCY_DESCRIPTION = "The average poll latency";
    private static final String POLL_MAX_LATENCY_DESCRIPTION = "The maximum poll latency";
    private static final String POLL_AVG_RECORDS_DESCRIPTION = "The average number of records polled from consumer within an iteration";
    private static final String POLL_MAX_RECORDS_DESCRIPTION = "The maximum number of records polled from consumer within an iteration";
    private static final String PROCESS_DESCRIPTION = "calls to process";
    private static final String PROCESS_TOTAL_DESCRIPTION = TOTAL_DESCRIPTION + PROCESS_DESCRIPTION;
    private static final String PROCESS_RATE_DESCRIPTION = RATE_DESCRIPTION + PROCESS_DESCRIPTION;
    private static final String PROCESS_AVG_LATENCY_DESCRIPTION = "The average process latency";
    private static final String PROCESS_MAX_LATENCY_DESCRIPTION = "The maximum process latency";
    private static final String PROCESS_AVG_RECORDS_DESCRIPTION = "The average number of records processed within an iteration";
    private static final String PROCESS_MAX_RECORDS_DESCRIPTION = "The maximum number of records processed within an iteration";
    private static final String PUNCTUATE_DESCRIPTION = "calls to punctuate";
    private static final String PUNCTUATE_TOTAL_DESCRIPTION = TOTAL_DESCRIPTION + PUNCTUATE_DESCRIPTION;
    private static final String PUNCTUATE_RATE_DESCRIPTION = RATE_DESCRIPTION + PUNCTUATE_DESCRIPTION;
    private static final String PUNCTUATE_AVG_LATENCY_DESCRIPTION = "The average punctuate latency";
    private static final String PUNCTUATE_MAX_LATENCY_DESCRIPTION = "The maximum punctuate latency";
    private static final String PROCESS_RATIO_DESCRIPTION =
        WINDOWED_RATIO_DESCRIPTION_PREFIX + THREAD_TIME_UNIT_DESCRIPTION +
            "processing active tasks to the total elapsed time in that window.";
    private static final String PUNCTUATE_RATIO_DESCRIPTION =
        WINDOWED_RATIO_DESCRIPTION_PREFIX + THREAD_TIME_UNIT_DESCRIPTION +
            "punctuating active tasks to the total elapsed time in that window.";
    private static final String POLL_RATIO_DESCRIPTION =
        WINDOWED_RATIO_DESCRIPTION_PREFIX + THREAD_TIME_UNIT_DESCRIPTION +
            "polling records from the consumer to the total elapsed time in that window.";
    private static final String COMMIT_RATIO_DESCRIPTION =
        WINDOWED_RATIO_DESCRIPTION_PREFIX + THREAD_TIME_UNIT_DESCRIPTION +
            "committing all tasks to the total elapsed time in that window.";
    private static final String BLOCKED_TIME_DESCRIPTION =
        "The total time the thread spent blocked on kafka in nanoseconds";
    private static final String THREAD_START_TIME_DESCRIPTION =
        "The time that the thread was started";
    private static final String THREAD_STATE_DESCRIPTION =
        "The current state of the thread";

    public static Sensor createTaskSensor(final String threadId,
                                          final StreamsMetricsImpl streamsMetrics) {
        return invocationRateAndCountSensor(
            threadId,
            CREATE_TASK,
            CREATE_TASK_RATE_DESCRIPTION,
            CREATE_TASK_TOTAL_DESCRIPTION,
            RecordingLevel.INFO,
            streamsMetrics
        );
    }

    public static Sensor closeTaskSensor(final String threadId,