use of org.apache.storm.metrics2.DimensionalReporter in project storm by apache.
the class ConsoleStormReporter method init.
private void init(MetricRegistry registry, MetricRegistryProvider metricRegistryProvider, Map<String, Object> reporterConf) {
LOG.debug("Preparing ConsoleReporter");
ConsoleReporter.Builder builder = ConsoleReporter.forRegistry(registry);
builder.outputTo(System.out);
Locale locale = ClientMetricsUtils.getMetricsReporterLocale(reporterConf);
if (locale != null) {
builder.formattedFor(locale);
}
TimeUnit rateUnit = ClientMetricsUtils.getMetricsRateUnit(reporterConf);
if (rateUnit != null) {
builder.convertRatesTo(rateUnit);
}
TimeUnit durationUnit = ClientMetricsUtils.getMetricsDurationUnit(reporterConf);
if (durationUnit != null) {
builder.convertDurationsTo(durationUnit);
}
StormMetricsFilter filter = getMetricsFilter(reporterConf);
if (filter != null) {
builder.filter(filter);
}
// defaults to 10
reportingPeriod = getReportPeriod(reporterConf);
// defaults to seconds
reportingPeriodUnit = getReportPeriodUnit(reporterConf);
ScheduledReporter consoleReporter = builder.build();
boolean reportDimensions = isReportDimensionsEnabled(reporterConf);
if (reportDimensions) {
if (metricRegistryProvider == null) {
throw new RuntimeException("MetricRegistryProvider is required to enable reporting dimensions");
}
if (rateUnit == null) {
rateUnit = TimeUnit.SECONDS;
}
if (durationUnit == null) {
durationUnit = TimeUnit.MILLISECONDS;
}
DimensionalReporter dimensionalReporter = new DimensionalReporter(metricRegistryProvider, consoleReporter, this, "ConsoleDimensionalReporter", filter, rateUnit, durationUnit, null, true);
reporter = dimensionalReporter;
} else {
reporter = consoleReporter;
}
}
Aggregations