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

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


The following commit(s) were added to refs/heads/main by this push:
     new fcd24d826 [server] Add rack label for tablet server metrics (#1468)
fcd24d826 is described below

commit fcd24d82668a6a56b827a20c7ccc0f68d56facdb
Author: Liebing <[email protected]>
AuthorDate: Thu Aug 7 20:52:36 2025 +0800

    [server] Add rack label for tablet server metrics (#1468)
    
    Co-authored-by: Liebing <[email protected]>
---
 .../com/alibaba/fluss/server/metrics/ServerMetricUtils.java    |  9 +++++++--
 .../fluss/server/metrics/group/TabletServerMetricGroup.java    | 10 +++++++++-
 .../java/com/alibaba/fluss/server/tablet/TabletServer.java     |  1 +
 .../fluss/server/metrics/group/TestingMetricGroups.java        |  2 +-
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git 
a/fluss-server/src/main/java/com/alibaba/fluss/server/metrics/ServerMetricUtils.java
 
b/fluss-server/src/main/java/com/alibaba/fluss/server/metrics/ServerMetricUtils.java
index b3b1d1772..89ad18338 100644
--- 
a/fluss-server/src/main/java/com/alibaba/fluss/server/metrics/ServerMetricUtils.java
+++ 
b/fluss-server/src/main/java/com/alibaba/fluss/server/metrics/ServerMetricUtils.java
@@ -31,6 +31,7 @@ import 
com.alibaba.fluss.server.metrics.group.TabletServerMetricGroup;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.annotation.Nullable;
 import javax.management.AttributeNotFoundException;
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanException;
@@ -79,9 +80,13 @@ public class ServerMetricUtils {
     }
 
     public static TabletServerMetricGroup createTabletServerGroup(
-            MetricRegistry registry, String clusterId, String hostname, int 
serverId) {
+            MetricRegistry registry,
+            String clusterId,
+            @Nullable String rack,
+            String hostname,
+            int serverId) {
         TabletServerMetricGroup tabletServerMetricGroup =
-                new TabletServerMetricGroup(registry, clusterId, hostname, 
serverId);
+                new TabletServerMetricGroup(registry, clusterId, rack, 
hostname, serverId);
         createAndInitializeStatusMetricGroup(tabletServerMetricGroup);
         return tabletServerMetricGroup;
     }
diff --git 
a/fluss-server/src/main/java/com/alibaba/fluss/server/metrics/group/TabletServerMetricGroup.java
 
b/fluss-server/src/main/java/com/alibaba/fluss/server/metrics/group/TabletServerMetricGroup.java
index 74623395d..66c49f1f4 100644
--- 
a/fluss-server/src/main/java/com/alibaba/fluss/server/metrics/group/TabletServerMetricGroup.java
+++ 
b/fluss-server/src/main/java/com/alibaba/fluss/server/metrics/group/TabletServerMetricGroup.java
@@ -38,6 +38,7 @@ public class TabletServerMetricGroup extends 
AbstractMetricGroup {
             MapUtils.newConcurrentHashMap();
 
     protected final String clusterId;
+    protected final String rack;
     protected final String hostname;
     protected final int serverId;
 
@@ -49,9 +50,10 @@ public class TabletServerMetricGroup extends 
AbstractMetricGroup {
     private final Counter delayedFetchFromClientExpireCount;
 
     public TabletServerMetricGroup(
-            MetricRegistry registry, String clusterId, String hostname, int 
serverId) {
+            MetricRegistry registry, String clusterId, String rack, String 
hostname, int serverId) {
         super(registry, new String[] {clusterId, hostname, NAME}, null);
         this.clusterId = clusterId;
+        this.rack = rack;
         this.hostname = hostname;
         this.serverId = serverId;
 
@@ -75,6 +77,12 @@ public class TabletServerMetricGroup extends 
AbstractMetricGroup {
     @Override
     protected final void putVariables(Map<String, String> variables) {
         variables.put("cluster_id", clusterId);
+        if (rack != null) {
+            variables.put("rack", rack);
+        } else {
+            // The value of an empty string indicates no rack
+            variables.put("rack", "");
+        }
         variables.put("host", hostname);
         variables.put("server_id", String.valueOf(serverId));
     }
diff --git 
a/fluss-server/src/main/java/com/alibaba/fluss/server/tablet/TabletServer.java 
b/fluss-server/src/main/java/com/alibaba/fluss/server/tablet/TabletServer.java
index 76a75eb50..635a15f11 100644
--- 
a/fluss-server/src/main/java/com/alibaba/fluss/server/tablet/TabletServer.java
+++ 
b/fluss-server/src/main/java/com/alibaba/fluss/server/tablet/TabletServer.java
@@ -177,6 +177,7 @@ public class TabletServer extends ServerBase {
                     ServerMetricUtils.createTabletServerGroup(
                             metricRegistry,
                             ServerMetricUtils.validateAndGetClusterId(conf),
+                            rack,
                             endpoints.get(0).getHost(),
                             serverId);
 
diff --git 
a/fluss-server/src/test/java/com/alibaba/fluss/server/metrics/group/TestingMetricGroups.java
 
b/fluss-server/src/test/java/com/alibaba/fluss/server/metrics/group/TestingMetricGroups.java
index 065666f21..0ef97e641 100644
--- 
a/fluss-server/src/test/java/com/alibaba/fluss/server/metrics/group/TestingMetricGroups.java
+++ 
b/fluss-server/src/test/java/com/alibaba/fluss/server/metrics/group/TestingMetricGroups.java
@@ -25,7 +25,7 @@ import com.alibaba.fluss.metrics.registry.NOPMetricRegistry;
 public class TestingMetricGroups {
 
     public static final TabletServerMetricGroup TABLET_SERVER_METRICS =
-            new TabletServerMetricGroup(NOPMetricRegistry.INSTANCE, "fluss", 
"host", 0);
+            new TabletServerMetricGroup(NOPMetricRegistry.INSTANCE, "fluss", 
"host", "rack", 0);
 
     public static final CoordinatorMetricGroup COORDINATOR_METRICS =
             new CoordinatorMetricGroup(NOPMetricRegistry.INSTANCE, "cluster1", 
"host", "0");

Reply via email to