Skip to content

Commit 453c47e

Browse files
committed
[server] Add cluster_id tag for client metric group
1 parent 58292a0 commit 453c47e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

fluss-rpc/src/main/java/org/apache/fluss/rpc/metrics/ClientMetricGroup.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import org.apache.fluss.metrics.groups.AbstractMetricGroup;
2222
import org.apache.fluss.metrics.registry.MetricRegistry;
2323

24+
import javax.annotation.Nullable;
25+
2426
import java.util.Map;
2527

2628
/** The metric group for clients. */
@@ -29,10 +31,16 @@ public class ClientMetricGroup extends AbstractMetricGroup {
2931
private static final String NAME = "client";
3032

3133
private final String clientId;
34+
private final @Nullable String clusterId;
3235

3336
public ClientMetricGroup(MetricRegistry registry, String clientId) {
37+
this(registry, null, clientId);
38+
}
39+
40+
public ClientMetricGroup(MetricRegistry registry, @Nullable String clusterId, String clientId) {
3441
super(registry, new String[] {NAME}, null);
3542
this.clientId = clientId;
43+
this.clusterId = clusterId;
3644
}
3745

3846
@Override
@@ -43,6 +51,11 @@ protected String getGroupName(CharacterFilter filter) {
4351
@Override
4452
protected final void putVariables(Map<String, String> variables) {
4553
variables.put("client_id", clientId);
54+
if (clusterId != null) {
55+
variables.put("cluster_id", clusterId);
56+
} else {
57+
variables.put("cluster_id", "");
58+
}
4659
}
4760

4861
public MetricRegistry getMetricRegistry() {

fluss-server/src/main/java/org/apache/fluss/server/tablet/TabletServer.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ protected void startServices() throws Exception {
202202
// rpc client to sent request to the tablet server where the leader replica is located
203203
// to fetch log.
204204
this.clientMetricGroup =
205-
new ClientMetricGroup(metricRegistry, SERVER_NAME + "-" + serverId);
205+
new ClientMetricGroup(
206+
metricRegistry,
207+
ServerMetricUtils.validateAndGetClusterId(conf),
208+
SERVER_NAME + "-" + serverId);
206209
this.rpcClient = RpcClient.create(conf, clientMetricGroup, true);
207210

208211
CoordinatorGateway coordinatorGateway =

0 commit comments

Comments
 (0)