stevenschlansker commented on code in PR #20328:
URL: https://github.com/apache/kafka/pull/20328#discussion_r2408935842


##########
clients/src/main/java/org/apache/kafka/common/telemetry/internals/TelemetryMetricNamingConvention.java:
##########
@@ -111,14 +114,16 @@ private static String cleanMetric(String metric) {
      * @return the new map with keys replaced by snake_case representations.
      */
     private static Map<String, String> cleanTags(Map<String, String> raw) {
-        return raw.entrySet()
-            .stream()
-            .collect(Collectors.toMap(s -> clean(s.getKey(), TAG_JOINER), 
Entry::getValue));
+        Map<String, String> result = new HashMap<>();
+        raw.forEach((k, v) -> {
+            result.put(clean(k, TAG_JOINER).intern(), v.intern());
+        });
+        return result;
     }
 
     private static String clean(String raw, String joiner) {
         Objects.requireNonNull(raw, "metric data cannot be null");
         String lowerCase = raw.toLowerCase(Locale.ROOT);
-        return lowerCase.replaceAll("-", joiner);
+        return DASH_PATTERN.matcher(lowerCase).replaceAll(joiner);

Review Comment:
   JDK 25 impl:
   ```
       public String replaceAll(String regex, String replacement) {
           return Pattern.compile(regex).matcher(this).replaceAll(replacement);
       }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to