This is an automated email from the ASF dual-hosted git repository.

dlmarion pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
     new 9c9bd711cf Use MetricsUtil.formatString in more places for normalizing 
tag values (#6334)
9c9bd711cf is described below

commit 9c9bd711cf13450719c9a4d640c42938deeaf9dd
Author: Dave Marion <[email protected]>
AuthorDate: Fri Apr 24 12:13:29 2026 -0400

    Use MetricsUtil.formatString in more places for normalizing tag values 
(#6334)
---
 .../java/org/apache/accumulo/core/metrics/MetricsInfo.java     | 10 +++++-----
 .../org/apache/accumulo/server/metrics/MetricsInfoImpl.java    |  3 ++-
 .../src/main/java/org/apache/accumulo/compactor/Compactor.java |  3 ++-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/metrics/MetricsInfo.java 
b/core/src/main/java/org/apache/accumulo/core/metrics/MetricsInfo.java
index ba79378a29..0b689b8e43 100644
--- a/core/src/main/java/org/apache/accumulo/core/metrics/MetricsInfo.java
+++ b/core/src/main/java/org/apache/accumulo/core/metrics/MetricsInfo.java
@@ -50,7 +50,7 @@ public interface MetricsInfo {
   static Tag instanceNameTag(final String instanceName) {
     Objects.requireNonNull(instanceName,
         "cannot create the tag without providing the instance name");
-    return Tag.of(INSTANCE_NAME_TAG_KEY, instanceName);
+    return Tag.of(INSTANCE_NAME_TAG_KEY, 
MetricsUtil.formatString(instanceName));
   }
 
   /**
@@ -60,7 +60,7 @@ public interface MetricsInfo {
    */
   static Tag processTag(final String processName) {
     Objects.requireNonNull(processName, "cannot create the tag without 
providing the process name");
-    return Tag.of(PROCESS_NAME_TAG_KEY, processName);
+    return Tag.of(PROCESS_NAME_TAG_KEY, MetricsUtil.formatString(processName));
   }
 
   /**
@@ -70,9 +70,9 @@ public interface MetricsInfo {
    */
   static Tag resourceGroupTag(final ResourceGroupId resourceGroupName) {
     if (resourceGroupName == null) {
-      return Tag.of(RESOURCE_GROUP_TAG_KEY, "NOT_PROVIDED");
+      return Tag.of(RESOURCE_GROUP_TAG_KEY, 
MetricsUtil.formatString("NOT_PROVIDED"));
     }
-    return Tag.of(RESOURCE_GROUP_TAG_KEY, resourceGroupName.canonical());
+    return Tag.of(RESOURCE_GROUP_TAG_KEY, 
MetricsUtil.formatString(resourceGroupName.canonical()));
   }
 
   /**
@@ -84,7 +84,7 @@ public interface MetricsInfo {
   static List<Tag> addressTags(final HostAndPort hostAndPort) {
     Objects.requireNonNull(hostAndPort, "cannot create the tag without 
providing the hostAndPort");
     List<Tag> tags = new ArrayList<>(2);
-    tags.add(Tag.of(HOST_TAG_KEY, hostAndPort.getHost()));
+    tags.add(Tag.of(HOST_TAG_KEY, 
MetricsUtil.formatString(hostAndPort.getHost())));
     int port = hostAndPort.getPort();
     if (port != 0) {
       tags.add(Tag.of(PORT_TAG_KEY, Integer.toString(hostAndPort.getPort())));
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsInfoImpl.java
 
b/server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsInfoImpl.java
index 1dbadab031..9bb8b2cae6 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsInfoImpl.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsInfoImpl.java
@@ -31,6 +31,7 @@ import org.apache.accumulo.core.classloader.ClassLoaderUtil;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.metrics.MetricsInfo;
 import org.apache.accumulo.core.metrics.MetricsProducer;
+import org.apache.accumulo.core.metrics.MetricsUtil;
 import org.apache.accumulo.core.metrics.MonitorMeterRegistry;
 import org.apache.accumulo.core.spi.metrics.MeterRegistryFactory;
 import org.apache.accumulo.core.util.threads.ThreadPools;
@@ -136,7 +137,7 @@ public class MetricsInfoImpl implements MetricsInfo {
       for (String userTag : userTagList) {
         String[] tagParts = userTag.split("=");
         if (tagParts.length == 2) {
-          Tag tag = Tag.of(tagParts[0], tagParts[1]);
+          Tag tag = Tag.of(tagParts[0], MetricsUtil.formatString(tagParts[1]));
           tags.add(tag);
         } else {
           LOG.warn("Malformed user metric tag: {} in property {}", userTag,
diff --git 
a/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java 
b/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java
index 8b5ed2a645..4a8df5602b 100644
--- 
a/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java
+++ 
b/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java
@@ -101,6 +101,7 @@ import 
org.apache.accumulo.core.metadata.schema.TabletMetadata;
 import org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType;
 import org.apache.accumulo.core.metrics.MetricsInfo;
 import org.apache.accumulo.core.metrics.MetricsProducer;
+import org.apache.accumulo.core.metrics.MetricsUtil;
 import org.apache.accumulo.core.rpc.ThriftUtil;
 import org.apache.accumulo.core.rpc.clients.ThriftClientTypes;
 import org.apache.accumulo.core.securityImpl.thrift.TCredentials;
@@ -272,7 +273,7 @@ public class Compactor extends AbstractServer implements 
MetricsProducer, Compac
   @Override
   public void registerMetrics(MeterRegistry registry) {
     super.registerMetrics(registry);
-    final String rgName = getResourceGroup().canonical();
+    final String rgName = 
MetricsUtil.formatString(getResourceGroup().canonical());
     FunctionCounter.builder(COMPACTOR_ENTRIES_READ.getName(), this, 
Compactor::getTotalEntriesRead)
         .description(COMPACTOR_ENTRIES_READ.getDescription())
         .tags(List.of(Tag.of("queue.id", rgName))).register(registry);

Reply via email to