.convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .withLoggingLevel(LoggingLevel.valueOf(level)) .build(); reporter.start(MetastoreConf.getTimeVar(conf,
@Override protected Slf4jReporter createInstance() { final Slf4jReporter.Builder reporter = Slf4jReporter.forRegistry(getMetricRegistry()); if (hasProperty(DURATION_UNIT)) { reporter.convertDurationsTo(getProperty(DURATION_UNIT, TimeUnit.class)); } if (hasProperty(RATE_UNIT)) { reporter.convertRatesTo(getProperty(RATE_UNIT, TimeUnit.class)); } reporter.filter(getMetricFilter()); reporter.prefixedWith(getPrefix()); if (hasProperty(MARKER)) { reporter.markWith(MarkerFactory.getMarker(getProperty(MARKER))); } if (hasProperty(LOGGER)) { reporter.outputTo(LoggerFactory.getLogger(getProperty(LOGGER))); } if (hasProperty(LEVEL)) { reporter.withLoggingLevel(getProperty(LEVEL, LoggingLevel.class)); } return reporter.build(); }
@Override public void prepare(Config config, MetricRegistry registry) { reporter = Slf4jReporter.forRegistry(registry) .outputTo(LoggerFactory.getLogger("org.apache.eagle.alert.metric")) .withLoggingLevel(config.hasPath("level") ? getLoggingLevel(config.getString("level")) : Slf4jReporter.LoggingLevel.INFO) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); }
.withLoggingLevel( Slf4jReporter.LoggingLevel.valueOf( config.string( "reports.slf4j.level" ).toUpperCase( US ) )
@Bean(name = "macMetricRegistry") public MacGyverMetricRegistry macMetricRegistry() { MacGyverMetricRegistry registry = new MacGyverMetricRegistry(); SharedMetricRegistries.add("macMetricRegistry", registry); Slf4jReporter r = Slf4jReporter.forRegistry(registry) .withLoggingLevel(LoggingLevel.DEBUG) .convertDurationsTo(TimeUnit.MILLISECONDS) .convertRatesTo(TimeUnit.SECONDS) .outputTo(LoggerFactory.getLogger("io.macgyver.metrics")) .build(); r.start(60, TimeUnit.SECONDS); return registry; }
@Before public void setUp() { final MetricRegistry metrics = new MetricRegistry(); metrics.registerAll(new MemoryUsageGaugeSet()); metrics.registerAll(new GarbageCollectorMetricSet()); metricReporter = Slf4jReporter.forRegistry(metrics) .filter((name, metric) -> name.matches("(.*heap|pools.PS.*).usage")) .withLoggingLevel(Slf4jReporter.LoggingLevel.DEBUG) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); metricReporter.start(60, TimeUnit.SECONDS); }
private static Slf4jReporter newSlf4jReporter(TimeValue logInterval) { Slf4jReporter reporter = Slf4jReporter.forRegistry(Metrics.registry()) .convertDurationsTo(MILLISECONDS) .convertRatesTo(SECONDS) .outputTo(LoggerFactory.getLogger("cbes.metrics")) .withLoggingLevel(Slf4jReporter.LoggingLevel.INFO) .build(); if (logInterval.duration() > 0) { reporter.start(logInterval.duration(), logInterval.duration(), logInterval.timeUnit()); } return reporter; }
public CodahaleMetricsAssembler withSlf4jReporter( Slf4jReporter.LoggingLevel level, long period, TimeUnit timeunit ) { declaration.reportersFactories.add( metricRegistry -> { Slf4jReporter reporter = Slf4jReporter.forRegistry( metricRegistry ).withLoggingLevel( level ).build(); reporter.start( period, timeunit ); return reporter; }); return this; }
MetricRegistry createMetricRegistry() { MetricRegistry registry = new MetricRegistry(); final Slf4jReporter reporter = Slf4jReporter.forRegistry(registry) .outputTo(LOG) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .withLoggingLevel(Slf4jReporter.LoggingLevel.DEBUG) .build(); reporter.start(DEFAULT_REPORTING_INTERVAL_SECONDS, TimeUnit.SECONDS); return registry; }
@Override public void configureReporters(final MetricRegistry metricRegistry) { Slf4jReporter .forRegistry(metricRegistry) .outputTo(getLogger(logger)) .withLoggingLevel(INFO) .build() .start(periodMinutes, MINUTES); }