/** * Create a {@link Slf4jReporter} attached to the Titan Metrics registry. * <p> * If {@code loggerName} is null, or if it is non-null but * {@link LoggerFactory#getLogger(loggerName)} returns null, then Metrics's * default Slf4j logger name is used instead. * * @param reportInterval * time to wait between writing metrics to the Slf4j * logger * @param loggerName * the name of the Slf4j logger that receives metrics */ public synchronized void addSlf4jReporter(Duration reportInterval, String loggerName) { if (null != slf4jReporter) { log.debug("Metrics Slf4jReporter already active; not creating another"); return; } Slf4jReporter.Builder b = Slf4jReporter.forRegistry(getRegistry()); if (null != loggerName) { Logger l = LoggerFactory.getLogger(loggerName); if (null != l) { b.outputTo(l); } else { log.error("Logger with name {} could not be obtained", loggerName); } } slf4jReporter = b.build(); slf4jReporter.start(reportInterval.toMillis(), TimeUnit.MILLISECONDS); }
/** * Create a {@link Slf4jReporter} attached to the JanusGraph Metrics registry. * <p> * If {@code loggerName} is null, or if it is non-null but * {@link LoggerFactory#getLogger(Class loggerName)} returns null, then Metrics's * default Slf4j logger name is used instead. * * @param reportInterval * time to wait between writing metrics to the Slf4j * logger * @param loggerName * the name of the Slf4j logger that receives metrics */ public synchronized void addSlf4jReporter(Duration reportInterval, String loggerName) { if (null != slf4jReporter) { log.debug("Metrics Slf4jReporter already active; not creating another"); return; } Slf4jReporter.Builder b = Slf4jReporter.forRegistry(getRegistry()); if (null != loggerName) { Logger l = LoggerFactory.getLogger(loggerName); if (null != l) { b.outputTo(l); } else { log.error("Logger with name {} could not be obtained", loggerName); } } slf4jReporter = b.build(); slf4jReporter.start(reportInterval.toMillis(), TimeUnit.MILLISECONDS); }
.convertDurationsTo(TimeUnit.MILLISECONDS) .withLoggingLevel(LoggingLevel.valueOf(level)) .build(); reporter.start(MetastoreConf.getTimeVar(conf, MetastoreConf.ConfVars.METRICS_SLF4J_LOG_FREQUENCY_MINS, TimeUnit.SECONDS), TimeUnit.SECONDS);
private ScheduledReporter createAndGetConfiguredSlf4jReporter(String slf4jLogger) { LOG.info("Configuring stats with SLF4J with logger {}", slf4jLogger); return Slf4jReporter.forRegistry(metrics) .outputTo(LoggerFactory.getLogger(slf4jLogger)) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); }
private ScheduledReporter createAndGetConfiguredSlf4jReporter(String slf4jLogger) { LOG.info("Configuring stats with SLF4J with logger {}", slf4jLogger); return Slf4jReporter.forRegistry(metrics) .outputTo(LoggerFactory.getLogger(slf4jLogger)) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); }
/** * Initialize metrics. */ protected void initializeMetrics() { if (getInstanceSettings().isLogMetrics()) { this.metricsReporter = Slf4jReporter.forRegistry(getMetricRegistry()).convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS).build(); getMetricsReporter().start(20, TimeUnit.SECONDS); } else { getLogger().info(MicroserviceMessages.METRICS_REPORTING_DISABLED); } }
@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(); }
private static void setupSlf4jReporting(MetricRegistry metrics) { if (!metricsSlf4jReportingEnabled) return; MetricFilter mpTriggerFilter = (name, metric) -> !name.equals(mpTrigger); Slf4jReporter slf4jReporter = Slf4jReporter.forRegistry(metrics) .convertDurationsTo(TimeUnit.MICROSECONDS) .convertRatesTo(TimeUnit.SECONDS) .outputTo(LoggerFactory.getLogger("org.corfudb.metricsdata")) .filter(mpTriggerFilter) .build(); slf4jReporter.start(metricsLogInterval, TimeUnit.SECONDS); }
private static Slf4jReporter getLogReporter() { if (config.getBoolean(METRICS_LOG_OUTPUT_ENABLED)) { Slf4jReporter reporter = Slf4jReporter.forRegistry(getInstance()).outputTo(logger) .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build(); reporter.start(config.getInt(METRICS_LOG_OUTPUT_INTERVAL), TimeUnit.SECONDS); return reporter; } else { return null; } } }
@Override public void report(MetricRegistry metricRegistry) { final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry) .outputTo(LoggerFactory.getLogger(JbootSlf4jReporter.class)) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(1, TimeUnit.MINUTES); } }
/** * Create a {@link Slf4jReporter} attached to the {@code MetricsRegistry}. * <p/> * If {@code loggerName} is null, or if it is non-null but * LoggerFactory.getLogger(loggerName) returns null, then Metrics's * default Slf4j logger name is used instead. * * @param reportIntervalInMS milliseconds to wait between writing metrics to the Slf4j * logger * @param loggerName the name of the Slf4j logger that receives metrics */ public synchronized void addSlf4jReporter(final long reportIntervalInMS, final String loggerName) { if (null != slf4jReporter) { log.debug("Metrics Slf4jReporter already active; not creating another"); return; } Slf4jReporter.Builder b = Slf4jReporter.forRegistry(getRegistry()); if (null != loggerName) { Logger l = LoggerFactory.getLogger(loggerName); if (null != l) { b.outputTo(l); } else { log.error("Logger with name {} could not be obtained", loggerName); } } slf4jReporter = b.build(); slf4jReporter.start(reportIntervalInMS, TimeUnit.MILLISECONDS); log.info("Configured Metrics Slf4jReporter configured with interval={}ms and loggerName={}", reportIntervalInMS, loggerName); }
@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(); }
.convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build();
@Before public void setupOrg() { originalShardSize = ConfigurationManager.getConfigInstance().getProperty( GraphFig.SHARD_SIZE ); originalShardTimeout = ConfigurationManager.getConfigInstance().getProperty( GraphFig.SHARD_CACHE_TIMEOUT ); originalShardDelta = ConfigurationManager.getConfigInstance().getProperty( GraphFig.SHARD_MIN_DELTA ); ConfigurationManager.getConfigInstance().setProperty( GraphFig.SHARD_SIZE, 10000 ); final long cacheTimeout = 1000; //set our cache timeout to the above value ConfigurationManager.getConfigInstance().setProperty( GraphFig.SHARD_CACHE_TIMEOUT, cacheTimeout ); final long minDelta = ( long ) ( cacheTimeout * 2.5 ); ConfigurationManager.getConfigInstance().setProperty( GraphFig.SHARD_MIN_DELTA, minDelta ); // get the system property of the UUID to use. If one is not set, use the defualt String uuidString = System.getProperty( "org.id", "80a42760-b699-11e3-a5e2-0800200c9a66" ); scope = new ApplicationScopeImpl( IdGenerator.createId(UUIDGenerator.newTimeUUID(), "test" ) ); reporter = Slf4jReporter.forRegistry( registry ).outputTo(logger).convertRatesTo( TimeUnit.SECONDS ) .convertDurationsTo( TimeUnit.MILLISECONDS ).build(); reporter.start( 10, TimeUnit.SECONDS ); }
@Before public void setupIndexAndMeters() { final String userAppId = indexTestFig.getApplicationId(); //if it's unset, generate one final String uniqueIdentifier = UUIDGenerator.newTimeUUID().toString(); //use the appId supplied, or generate one final UUID applicationUUID = UUID.fromString( userAppId ); final Id applicationId = new SimpleId( applicationUUID, "application" ); batchWriteTPS = metricsFactory.getMeter( IndexLoadTestsIT.class, "batch.write_tps" ); batchWriteTimer = metricsFactory.getTimer( IndexLoadTestsIT.class, "batch.write" ); queryTps = metricsFactory.getMeter( IndexLoadTestsIT.class, "query.tps" ); queryTimer = metricsFactory.getTimer( IndexLoadTestsIT.class, "query.test" ); reporter = Slf4jReporter.forRegistry( metricsFactory.getRegistry() ).outputTo( log ).convertRatesTo( TimeUnit.SECONDS ) .convertDurationsTo( TimeUnit.MILLISECONDS ).build(); reporter.start( 30, TimeUnit.SECONDS ); }
private static Slf4jReporter getLogReporter() { if (METRICS_LOG_OUTPUT_ENABLED) { Slf4jReporter reporter = Slf4jReporter.forRegistry(REGISTRY) .outputTo(logger) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(METRICS_LOG_OUTPUT_INTERVAL, TimeUnit.SECONDS); return reporter; } return null; } }
@Before public void startReporting() { reporter = Slf4jReporter.forRegistry( registry ).outputTo( logger ) .convertRatesTo( TimeUnit.SECONDS ) .convertDurationsTo( TimeUnit.MILLISECONDS ).build(); reporter.start( 10, TimeUnit.SECONDS ); }
@Override public void startReport() { LOG.info("Starting metrics report!"); reporter = Slf4jReporter.forRegistry(metrics) .outputTo(LoggerFactory.getLogger(KAA_METRICS_LOGGER_NAME)) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS).build(); registerSystemMonitor(); reporter.start(30, TimeUnit.SECONDS); this.jmx = JmxReporter.forRegistry(this.metrics).inDomain(KAA_METRICS_LOGGER_NAME).build(); this.jmx.start(); }
@Before public void startReporting() { reporter = Slf4jReporter.forRegistry( registry ).outputTo( LOG ).convertRatesTo( TimeUnit.SECONDS ) .convertDurationsTo( TimeUnit.MILLISECONDS ).build(); reporter.start( 10, TimeUnit.SECONDS ); }
@Override public ScheduledReporter build(MetricRegistry registry) { final Slf4jReporter.Builder builder = Slf4jReporter.forRegistry(registry) .convertDurationsTo(getDurationUnit()) .convertRatesTo(getRateUnit()) .filter(getFilter()) .outputTo(getLogger()); if (markerName != null) { builder.markWith(MarkerFactory.getMarker(markerName)); } return builder.build(); } }