Skip to content

Commit fcd24d8

Browse files
LB-YuLiebing
andauthored
[server] Add rack label for tablet server metrics (#1468)
Co-authored-by: Liebing <[email protected]>
1 parent a55c4ac commit fcd24d8

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

fluss-server/src/main/java/com/alibaba/fluss/server/metrics/ServerMetricUtils.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.slf4j.Logger;
3232
import org.slf4j.LoggerFactory;
3333

34+
import javax.annotation.Nullable;
3435
import javax.management.AttributeNotFoundException;
3536
import javax.management.InstanceNotFoundException;
3637
import javax.management.MBeanException;
@@ -79,9 +80,13 @@ public static CoordinatorMetricGroup createCoordinatorGroup(
7980
}
8081

8182
public static TabletServerMetricGroup createTabletServerGroup(
82-
MetricRegistry registry, String clusterId, String hostname, int serverId) {
83+
MetricRegistry registry,
84+
String clusterId,
85+
@Nullable String rack,
86+
String hostname,
87+
int serverId) {
8388
TabletServerMetricGroup tabletServerMetricGroup =
84-
new TabletServerMetricGroup(registry, clusterId, hostname, serverId);
89+
new TabletServerMetricGroup(registry, clusterId, rack, hostname, serverId);
8590
createAndInitializeStatusMetricGroup(tabletServerMetricGroup);
8691
return tabletServerMetricGroup;
8792
}

fluss-server/src/main/java/com/alibaba/fluss/server/metrics/group/TabletServerMetricGroup.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class TabletServerMetricGroup extends AbstractMetricGroup {
3838
MapUtils.newConcurrentHashMap();
3939

4040
protected final String clusterId;
41+
protected final String rack;
4142
protected final String hostname;
4243
protected final int serverId;
4344

@@ -49,9 +50,10 @@ public class TabletServerMetricGroup extends AbstractMetricGroup {
4950
private final Counter delayedFetchFromClientExpireCount;
5051

5152
public TabletServerMetricGroup(
52-
MetricRegistry registry, String clusterId, String hostname, int serverId) {
53+
MetricRegistry registry, String clusterId, String rack, String hostname, int serverId) {
5354
super(registry, new String[] {clusterId, hostname, NAME}, null);
5455
this.clusterId = clusterId;
56+
this.rack = rack;
5557
this.hostname = hostname;
5658
this.serverId = serverId;
5759

@@ -75,6 +77,12 @@ public TabletServerMetricGroup(
7577
@Override
7678
protected final void putVariables(Map<String, String> variables) {
7779
variables.put("cluster_id", clusterId);
80+
if (rack != null) {
81+
variables.put("rack", rack);
82+
} else {
83+
// The value of an empty string indicates no rack
84+
variables.put("rack", "");
85+
}
7886
variables.put("host", hostname);
7987
variables.put("server_id", String.valueOf(serverId));
8088
}

fluss-server/src/main/java/com/alibaba/fluss/server/tablet/TabletServer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ protected void startServices() throws Exception {
177177
ServerMetricUtils.createTabletServerGroup(
178178
metricRegistry,
179179
ServerMetricUtils.validateAndGetClusterId(conf),
180+
rack,
180181
endpoints.get(0).getHost(),
181182
serverId);
182183

fluss-server/src/test/java/com/alibaba/fluss/server/metrics/group/TestingMetricGroups.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class TestingMetricGroups {
2626

2727
public static final TabletServerMetricGroup TABLET_SERVER_METRICS =
28-
new TabletServerMetricGroup(NOPMetricRegistry.INSTANCE, "fluss", "host", 0);
28+
new TabletServerMetricGroup(NOPMetricRegistry.INSTANCE, "fluss", "host", "rack", 0);
2929

3030
public static final CoordinatorMetricGroup COORDINATOR_METRICS =
3131
new CoordinatorMetricGroup(NOPMetricRegistry.INSTANCE, "cluster1", "host", "0");

0 commit comments

Comments
 (0)