[HUDI-2434] Make periodSeconds of GraphiteReporter configurable (#3667)
This commit is contained in:
@@ -1475,6 +1475,10 @@ public class HoodieWriteConfig extends HoodieConfig {
|
||||
return getString(HoodieMetricsGraphiteConfig.GRAPHITE_METRIC_PREFIX_VALUE);
|
||||
}
|
||||
|
||||
public int getGraphiteReportPeriodSeconds() {
|
||||
return getInt(HoodieMetricsGraphiteConfig.GRAPHITE_REPORT_PERIOD_IN_SECONDS);
|
||||
}
|
||||
|
||||
public String getJmxHost() {
|
||||
return getString(HoodieMetricsJmxConfig.JMX_HOST_NAME);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,12 @@ public class HoodieMetricsGraphiteConfig extends HoodieConfig {
|
||||
.sinceVersion("0.5.1")
|
||||
.withDocumentation("Standard prefix applied to all metrics. This helps to add datacenter, environment information for e.g");
|
||||
|
||||
public static final ConfigProperty<Integer> GRAPHITE_REPORT_PERIOD_IN_SECONDS = ConfigProperty
|
||||
.key(GRAPHITE_PREFIX + ".report.period.seconds")
|
||||
.defaultValue(30)
|
||||
.sinceVersion("0.10.0")
|
||||
.withDocumentation("Graphite reporting period in seconds. Default to 30.");
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #GRAPHITE_SERVER_HOST_NAME} and its methods instead
|
||||
*/
|
||||
@@ -126,6 +132,11 @@ public class HoodieMetricsGraphiteConfig extends HoodieConfig {
|
||||
return this;
|
||||
}
|
||||
|
||||
public HoodieMetricsGraphiteConfig.Builder periodSeconds(String periodSeconds) {
|
||||
hoodieMetricsGraphiteConfig.setValue(GRAPHITE_REPORT_PERIOD_IN_SECONDS, periodSeconds);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HoodieMetricsGraphiteConfig build() {
|
||||
hoodieMetricsGraphiteConfig.setDefaults(HoodieMetricsGraphiteConfig.class.getName());
|
||||
return hoodieMetricsGraphiteConfig;
|
||||
|
||||
@@ -42,6 +42,7 @@ public class MetricsGraphiteReporter extends MetricsReporter {
|
||||
private final HoodieWriteConfig config;
|
||||
private String serverHost;
|
||||
private int serverPort;
|
||||
private final int periodSeconds;
|
||||
|
||||
public MetricsGraphiteReporter(HoodieWriteConfig config, MetricRegistry registry) {
|
||||
this.registry = registry;
|
||||
@@ -56,12 +57,13 @@ public class MetricsGraphiteReporter extends MetricsReporter {
|
||||
}
|
||||
|
||||
this.graphiteReporter = createGraphiteReport();
|
||||
this.periodSeconds = config.getGraphiteReportPeriodSeconds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (graphiteReporter != null) {
|
||||
graphiteReporter.start(30, TimeUnit.SECONDS);
|
||||
graphiteReporter.start(periodSeconds, TimeUnit.SECONDS);
|
||||
} else {
|
||||
LOG.error("Cannot start as the graphiteReporter is null.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user