Search in sources :

Example 1 with DimensionalReporter

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;
    }
}
Also used : Locale(java.util.Locale) DimensionalReporter(org.apache.storm.metrics2.DimensionalReporter) ConsoleReporter(com.codahale.metrics.ConsoleReporter) TimeUnit(java.util.concurrent.TimeUnit) ScheduledReporter(com.codahale.metrics.ScheduledReporter) StormMetricsFilter(org.apache.storm.metrics2.filters.StormMetricsFilter)

Aggregations

ConsoleReporter (com.codahale.metrics.ConsoleReporter)1 ScheduledReporter (com.codahale.metrics.ScheduledReporter)1 Locale (java.util.Locale)1 TimeUnit (java.util.concurrent.TimeUnit)1 DimensionalReporter (org.apache.storm.metrics2.DimensionalReporter)1 StormMetricsFilter (org.apache.storm.metrics2.filters.StormMetricsFilter)1