1
0

[HUDI-2974] Make the prefix for metrics name configurable (#4274)

Co-authored-by: Rajesh Mahindra <rmahindra@Rajeshs-MacBook-Pro.local>
This commit is contained in:
rmahindra123
2021-12-10 19:42:20 -08:00
committed by GitHub
parent c48a2a125a
commit 9797fdfbb2
5 changed files with 21 additions and 3 deletions

View File

@@ -1628,6 +1628,10 @@ public class HoodieWriteConfig extends HoodieConfig {
return getBoolean(HoodieMetricsPrometheusConfig.PUSHGATEWAY_RANDOM_JOBNAME_SUFFIX);
}
public String getMetricReporterMetricsNamePrefix() {
return getStringOrDefault(HoodieMetricsConfig.METRICS_REPORTER_PREFIX);
}
/**
* memory configs.
*/

View File

@@ -22,6 +22,8 @@ import org.apache.hudi.common.config.ConfigClassProperty;
import org.apache.hudi.common.config.ConfigGroups;
import org.apache.hudi.common.config.ConfigProperty;
import org.apache.hudi.common.config.HoodieConfig;
import org.apache.hudi.common.table.HoodieTableConfig;
import org.apache.hudi.common.util.Option;
import org.apache.hudi.config.HoodieMetricsCloudWatchConfig;
import org.apache.hudi.metrics.MetricsReporterType;
@@ -63,6 +65,18 @@ public class HoodieMetricsConfig extends HoodieConfig {
.sinceVersion("0.6.0")
.withDocumentation("");
public static final ConfigProperty<String> METRICS_REPORTER_PREFIX = ConfigProperty
.key(METRIC_PREFIX + ".reporter.metricsname.prefix")
.defaultValue("")
.sinceVersion("0.11.0")
.withInferFunction(cfg -> {
if (cfg.contains(HoodieTableConfig.NAME)) {
return Option.of(cfg.getString(HoodieTableConfig.NAME));
}
return Option.empty();
})
.withDocumentation("The prefix given to the metrics names.");
// Enable metrics collection from executors
public static final ConfigProperty<String> EXECUTOR_METRICS_ENABLE = ConfigProperty
.key(METRIC_PREFIX + ".executor.enable")

View File

@@ -215,7 +215,7 @@ public class HoodieMetrics {
}
String getMetricsName(String action, String metric) {
return config == null ? null : String.format("%s.%s.%s", tableName, action, metric);
return config == null ? null : String.format("%s.%s.%s", config.getMetricReporterMetricsNamePrefix(), action, metric);
}
/**

View File

@@ -46,7 +46,7 @@ public class Metrics {
private Metrics(HoodieWriteConfig metricConfig) {
registry = new MetricRegistry();
commonMetricPrefix = metricConfig.getTableName();
commonMetricPrefix = metricConfig.getMetricReporterMetricsNamePrefix();
reporter = MetricsReporterFactory.createReporter(metricConfig, registry);
if (reporter == null) {
throw new RuntimeException("Cannot initialize Reporter.");

View File

@@ -74,7 +74,7 @@ public class HoodieDeltaStreamerMetrics implements Serializable {
}
String getMetricsName(String action, String metric) {
return config == null ? null : String.format("%s.%s.%s", tableName, action, metric);
return config == null ? null : String.format("%s.%s.%s", config.getMetricReporterMetricsNamePrefix(), action, metric);
}
public void updateDeltaStreamerMetrics(long durationInNs) {