ConsoleReporter reporter = new ConsoleReporter( Metrics.defaultRegistry(), System.out, MetricPredicate.ALL );
/** * Get metrics reporter * * @return ConsoleReporter */ public static ConsoleReporter metricsReporter() { return new ConsoleReporter(Metrics.defaultRegistry(), System.err, MetricPredicate.ALL); }
/** * Dump all the metrics to the PrintStream provided. * * @param out PrintStream to write metrics to. */ public void printToStream(PrintStream out) { out.println(""); new ConsoleReporter(registry, out, MetricPredicate.ALL).run(); }
/** * Enables the console reporter for the given metrics registry, and causes it to print to STDOUT * with the specified period and unrestricted output. * * @param metricsRegistry the metrics registry * @param period the period between successive outputs * @param unit the time unit of {@code period} */ public static void enable(MetricsRegistry metricsRegistry, long period, TimeUnit unit) { final ConsoleReporter reporter = new ConsoleReporter(metricsRegistry, System.out, MetricPredicate.ALL); reporter.start(period, unit); }
/** Dump metrics to stderr */ public void dumpMetricsToStderr() { new ConsoleReporter(System.err).run(); }
@Override public boolean enable() { try { PrintStream stream = null; if (outfile != null) { log.info("console reporting will be redirected to {} instead of stdout", outfile); stream = new PrintStream(outfile); } else { stream = System.out; } // static enable() methods omit the option of specifying a // predicate. Calling constructor and starting manually // instead final ConsoleReporter reporter = new ConsoleReporter(Metrics.defaultRegistry(), stream, getMetricPredicate()); reporter.start(getPeriod(), getRealTimeunit()); } catch (Exception e) { log.error("Failure while enabling console reporter", e); return false; } return true; }
@Override public boolean enable() { try { PrintStream stream = createPrintStream(); // static enable() methods omit the option of specifying a // predicate. Calling constructor and starting manually // instead final ConsoleReporter reporter = new ConsoleReporter( Metrics.defaultRegistry(), stream, MetricPredicateTransformer.generatePredicate(getPredicate())); reporter.start(getPeriod(), getRealTimeunit()); } catch (Exception e) { log.error("Failure while enabling console reporter", e); return false; } return true; }
new ConsoleReporter(System.err).run();