Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update metric system with cherry-pick Remove hostname from metrics key #18626

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/common/src/main/java/alluxio/conf/PropertyKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,13 @@ public String toString() {
.setScope(Scope.ALL)
.setConsistencyCheckLevel(ConsistencyCheckLevel.IGNORE)
.build();
public static final PropertyKey METRICS_KEY_INCLUDING_UNIQUE_ID_ENABLED =
booleanBuilder(Name.METRICS_KEY_INCLUDING_UNIQUE_ID_ENABLED)
.setDefaultValue(false)
.setDescription("Whether to include the unique id such as hostname in the metrcis key.")
.setConsistencyCheckLevel(ConsistencyCheckLevel.WARN)
.setScope(Scope.ALL)
.build();
public static final PropertyKey NETWORK_CONNECTION_AUTH_TIMEOUT =
durationBuilder(Name.NETWORK_CONNECTION_AUTH_TIMEOUT)
.setDefaultValue("30sec")
Expand Down Expand Up @@ -7810,6 +7817,8 @@ public static final class Name {
"alluxio.metrics.executor.task.warn.size";
public static final String METRICS_EXECUTOR_TASK_WARN_FREQUENCY =
"alluxio.metrics.executor.task.warn.frequency";
public static final String METRICS_KEY_INCLUDING_UNIQUE_ID_ENABLED =
"alluxio.metrics.key.including.unique.id.enabled";
public static final String NETWORK_CONNECTION_AUTH_TIMEOUT =
"alluxio.network.connection.auth.timeout";
public static final String NETWORK_CONNECTION_HEALTH_CHECK_TIMEOUT =
Expand Down
14 changes: 12 additions & 2 deletions core/common/src/main/java/alluxio/metrics/MetricsSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public final class MetricsSystem {
private static final ConcurrentHashMap<String, String> CACHED_METRICS = new ConcurrentHashMap<>();
private static int sResolveTimeout =
(int) Configuration.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS);
private static boolean sUniqueIDEnabled =
Configuration.getBoolean(PropertyKey.METRICS_KEY_INCLUDING_UNIQUE_ID_ENABLED);
// A map from AlluxioURI to corresponding cached escaped path.
private static final ConcurrentHashMap<AlluxioURI, String> CACHED_ESCAPED_PATH
= new ConcurrentHashMap<>();
Expand Down Expand Up @@ -482,10 +484,18 @@ public static String getPluginMetricName(String name) {
* @return the metric registry name
*/
private static String getMetricNameWithUniqueId(InstanceType instance, String name) {
String metricsNameWithInstanceType = addInstanceTypeToMetricsName(instance, name);
if (sUniqueIDEnabled) {
return Joiner.on(".").join(metricsNameWithInstanceType, sSourceNameSupplier.get());
}
return metricsNameWithInstanceType;
}

private static String addInstanceTypeToMetricsName(InstanceType instance, String name) {
if (name.startsWith(instance.toString())) {
return Joiner.on(".").join(name, sSourceNameSupplier.get());
return name;
}
return Joiner.on(".").join(instance, name, sSourceNameSupplier.get());
return Joiner.on(".").join(instance, name);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ public void getMetricNameTest() {
assertEquals("Cluster.counter", MetricsSystem.getMetricName("Cluster.counter"));
assertEquals("Master.timer", MetricsSystem.getMetricName("Master.timer"));
String workerGaugeName = "Worker.gauge";
assertNotEquals(workerGaugeName, MetricsSystem.getMetricName(workerGaugeName));
assertEquals(workerGaugeName, MetricsSystem.getMetricName(workerGaugeName));
assertTrue(MetricsSystem.getMetricName(workerGaugeName).startsWith(workerGaugeName));
String clientCounterName = "Client.counter";
assertNotEquals(clientCounterName, MetricsSystem.getMetricName(clientCounterName));
assertEquals(clientCounterName, MetricsSystem.getMetricName(clientCounterName));
assertTrue(MetricsSystem.getMetricName(clientCounterName).startsWith(clientCounterName));
}

Expand Down
Loading