/** * Create a {@link ConsoleReporter} attached to the Titan Metrics registry. * * @param reportInterval * time to wait between dumping metrics to the console */ public synchronized void addConsoleReporter(Duration reportInterval) { if (null != consoleReporter) { log.debug("Metrics ConsoleReporter already active; not creating another"); return; } consoleReporter = ConsoleReporter.forRegistry(getRegistry()).build(); consoleReporter.start(reportInterval.toMillis(), TimeUnit.MILLISECONDS); }
/** * Create a {@link ConsoleReporter} attached to the JanusGraph Metrics registry. * * @param reportInterval * time to wait between dumping metrics to the console */ public synchronized void addConsoleReporter(Duration reportInterval) { if (null != consoleReporter) { log.debug("Metrics ConsoleReporter already active; not creating another"); return; } consoleReporter = ConsoleReporter.forRegistry(getRegistry()).build(); consoleReporter.start(reportInterval.toMillis(), TimeUnit.MILLISECONDS); }
public ConsoleMetricsReporter(MetricRegistry registry, HiveConf conf) { reporter = ConsoleReporter.forRegistry(registry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); }
public ConsoleMetricsReporter(MetricRegistry registry, KylinConfig conf) { reporter = ConsoleReporter.forRegistry(registry).convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS).build(); }
/** * Creates a new {@link ConsoleSink} with a {@link Properties} and {@link MetricRegistry}. * * @param properties the properties which may contain polling period and unit properties * @param registry the metric registry to register */ public ConsoleSink(Properties properties, MetricRegistry registry) { mProperties = properties; mReporter = ConsoleReporter.forRegistry(registry).convertDurationsTo(TimeUnit.MILLISECONDS) .convertRatesTo(TimeUnit.SECONDS).build(); MetricsSystem.checkMinimalPollingPeriod(getPollUnit(), getPollPeriod()); }
@Override public void prepare(MetricRegistry metricsRegistry, Map<String, Object> topoConf) { LOG.debug("Preparing..."); ConsoleReporter.Builder builder = ConsoleReporter.forRegistry(metricsRegistry); builder.outputTo(System.out); Locale locale = ClientMetricsUtils.getMetricsReporterLocale(topoConf); if (locale != null) { builder.formattedFor(locale); } TimeUnit rateUnit = ClientMetricsUtils.getMetricsRateUnit(topoConf); if (rateUnit != null) { builder.convertRatesTo(rateUnit); } TimeUnit durationUnit = ClientMetricsUtils.getMetricsDurationUnit(topoConf); if (durationUnit != null) { builder.convertDurationsTo(durationUnit); } reporter = builder.build(); }
for (String reporterName : reporterNames) { if (reporterName.equals("console") || reporterName.endsWith("consolemetricsreporter")) { ConsoleReporter reporter = ConsoleReporter.forRegistry(registry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS)
@Override public void prepare(MetricRegistry registry, Map stormConf, Map reporterConf) { LOG.debug("Preparing ConsoleReporter"); ConsoleReporter.Builder builder = ConsoleReporter.forRegistry(registry); builder.outputTo(System.out); Locale locale = ClientMetricsUtils.getMetricsReporterLocale(stormConf); if (locale != null) { builder.formattedFor(locale); } TimeUnit rateUnit = ClientMetricsUtils.getMetricsRateUnit(stormConf); if (rateUnit != null) { builder.convertRatesTo(rateUnit); } TimeUnit durationUnit = ClientMetricsUtils.getMetricsDurationUnit(stormConf); 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); reporter = builder.build(); }
@Override public ScheduledReporter build(MetricRegistry registry) { return ConsoleReporter.forRegistry(registry) .convertDurationsTo(getDurationUnit()) .convertRatesTo(getRateUnit()) .filter(getFilter()) .formattedFor(getLocale()) .formattedFor(getTimeZone()) .outputTo(getOutput().get()) .build(); } }
syncInterval, traceFreq), ""); ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics). outputTo(System.out).convertRatesTo(TimeUnit.SECONDS).filter(MetricFilter.ALL).build(); reporter.start(30, TimeUnit.SECONDS);
public static void main(String[] args) throws Exception { final MetricRegistry metrics = new MetricRegistry(); final HadoopMetrics2Reporter metrics2Reporter = HadoopMetrics2Reporter.forRegistry(metrics).build( DefaultMetricsSystem.initialize("StandaloneTest"), // The application-level name "Test", // Component name "Test", // Component description "Test"); // Name for each metric record final ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(metrics).build(); MetricsSystem metrics2 = DefaultMetricsSystem.instance(); // Writes to stdout without a filename configuration // Will be invoked every 10seconds by default FileSink sink = new FileSink(); metrics2.register("filesink", "filesink", sink); sink.init(new SubsetConfiguration(null, null) { public String getString(String key) { if (key.equals("filename")) { return null; } return super.getString(key); } }); // How often should the dropwizard reporter be invoked metrics2Reporter.start(500, TimeUnit.MILLISECONDS); // How often will the dropwziard metrics be logged to the console consoleReporter.start(2, TimeUnit.SECONDS); generateMetrics(metrics, 5000, 25, TimeUnit.MILLISECONDS, metrics2Reporter, 10); }
/** * Create a {@link ConsoleReporter} attached to the {@code MetricsRegistry}. * * @param reportIntervalInMS milliseconds to wait between dumping metrics to the console */ public synchronized void addConsoleReporter(final long reportIntervalInMS) { if (null != consoleReporter) { log.debug("Metrics ConsoleReporter already active; not creating another"); return; } consoleReporter = ConsoleReporter.forRegistry(getRegistry()).build(); consoleReporter.start(reportIntervalInMS, TimeUnit.MILLISECONDS); log.info("Configured Metrics ConsoleReporter configured with report interval={}ms", reportIntervalInMS); }
@Override protected ConsoleReporter createInstance() { final ConsoleReporter.Builder reporter = ConsoleReporter.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()); if (hasProperty(CLOCK_REF)) { reporter.withClock(getPropertyRef(CLOCK_REF, Clock.class)); } if (hasProperty(OUTPUT_REF)) { reporter.outputTo(getPropertyRef(OUTPUT_REF, PrintStream.class)); } if (hasProperty(LOCALE)) { reporter.formattedFor(parseLocale(getProperty(LOCALE))); } if (hasProperty(TIMEZONE)) { reporter.formattedFor(TimeZone.getTimeZone(getProperty(TIMEZONE))); } return reporter.build(); }
@Override public String toString() { ByteArrayOutputStream os = new ByteArrayOutputStream(); try { PrintStream out = new PrintStream(os, true, StandardCharsets.UTF_8.name()); ConsoleReporter.forRegistry(metrics).outputTo(out).build().report(); return os.toString(StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } }
@Override public void createAndStartReporter(MetricRegistry metricRegistry, Map<String, Object> configuration) { ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry).build(); reporter.start(10, TimeUnit.SECONDS); } }
public ConsoleMetricsReporter(MetricRegistry registry, HiveConf conf) { reporter = ConsoleReporter.forRegistry(registry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); }
@Override public synchronized Reporter getReporter(MetricRegistry registry) { if (null == reporter) { reporter = ConsoleReporter.forRegistry(registry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); } return reporter; }
@Override public void report(MetricRegistry metricRegistry) { final ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(1, TimeUnit.MINUTES); } }
@Override public void configureReporters(MetricRegistry metricRegistry) { if (configurationContext.isPrintStreams()) { ConsoleReporter.forRegistry(metricRegistry).build().start(5, TimeUnit.SECONDS); } if (configurationContext.isStatsEnabled()) { SiddhiStreamReporter.forRegistry(metricRegistry, streamOperationServiceWithoutMetrics()).build().start(5, TimeUnit.SECONDS); } JmxReporter.forRegistry(metricRegistry).build().start(); }
@Override public ScheduledReporter build(MetricRegistry registry) { return ConsoleReporter.forRegistry(registry) .convertDurationsTo(getDurationUnit()) .convertRatesTo(getRateUnit()) .filter(getFilter()) .formattedFor(getLocale()) .formattedFor(getTimeZone()) .outputTo(getOutput().get()) .build(); } }