Refine search
/** * 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); }
@Override public void report() { mReporter.report(); }
@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); } } }
public ConsoleMetricsReporter(MetricRegistry registry, HiveConf conf) { reporter = ConsoleReporter.forRegistry(registry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); }
System.out.printf("\t %.2f string attributes per second\n", numStringAttributesPerSecond); ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(reportIntervalInSeconds, TimeUnit.SECONDS); reporter.stop(); abort.set(true); executor.shutdownNow();
ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(reportIntervalInSeconds, TimeUnit.SECONDS); for (int i = 0; i < numberOfThreads; i++) { final EventGenerator eventGenerator = useJexl ? } finally { reporter.stop(); reporter.report(); return null;
ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics) .convertRatesTo(TimeUnit.MILLISECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.report(); reporter.close(); System.out.printf("Total miliseconds elapsed: %d\n", afterResponse - beforeExec); System.out.printf("Miliseconds spent generating requests: %d\n", afterExec - beforeExec);
public static void main(final String[] args) { final MetricRegistry metricRegistry = new MetricRegistry(); new GcMemoryMetrics("demo", metricRegistry); final ConsoleReporter reporter = ConsoleReporter .forRegistry(metricRegistry) .build(); reporter.start(1, TimeUnit.SECONDS); while (true) { try { System.gc(); Thread.sleep(Duration.ofSeconds(1).toMillis()); } catch (@SuppressWarnings("unused") final InterruptedException e) { Thread.currentThread().interrupt(); break; } } reporter.stop(); reporter.close(); } }
@Override public void start() { reporter.start(1, TimeUnit.SECONDS); }
@Test public void testJVMMetrics() throws InterruptedException { LOG.info("Starting testJVMMetrics"); final MetricRegistry metrics = new MetricRegistry(); ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); metrics.registerAll(new MemoryUsageGaugeSet()); metrics.register("sample", (Gauge<Double>) () -> 0.1234); reporter.start(1, TimeUnit.SECONDS); reporter.close(); } }
public static void loadOrPrint(File templateFile, Stream<Map<String, Object>> data, MigrationOptions options){ String template = fileAsString(templateFile); Migrator migrator = new MigratorBuilder() .setUri(options.getUri()) .setMigrationOptions(options) .setKeyspace(options.getKeyspace()) .build(); if(options.isNo()){ migrator.print(template, data); } else { printInitMessage(options); migrator.getReporter().start(1, TimeUnit.MINUTES); try { migrator.load(template, data); } catch (Throwable e) { // This is to catch migration exceptions and return intelligible output messages StringBuilder message = CommonUtil.simplifyExceptionMessage(e); System.out.println("ERROR: Exception while loading data (disabling debug mode might skip and continue): " + message.toString()); } finally { migrator.getReporter().stop(); } printWholeCompletionMessage(options); } }
/** * Stop a {@link ConsoleReporter} previously created by a call to * {@link #addConsoleReporter(long)} and release it for GC. Idempotent * between calls to the associated add method. Does nothing before the first * call to the associated add method. */ public synchronized void removeConsoleReporter() { if (null != consoleReporter) consoleReporter.stop(); consoleReporter = null; }
@Override public void close() { reporter.close(); } }
private String getMetricReport(MetricRegistry registry) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(outputStream); ConsoleReporter reporter = ConsoleReporter.forRegistry(registry) .outputTo(ps) .build(); reporter.report(); return new String(outputStream.toByteArray()); }
public ConsoleMetricsReporter(MetricRegistry registry, KylinConfig conf) { reporter = ConsoleReporter.forRegistry(registry).convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS).build(); }
ConsoleReporter reporter = ConsoleReporter.forRegistry(SharedMetricRegistries.getOrCreate("metrics-registry")) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(1, TimeUnit.SECONDS); executor.submit(pipeline::start); Thread.sleep(2000); pipeline.stop(); reporter.stop();
ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics) .convertRatesTo(TimeUnit.MILLISECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.report(); reporter.close(); System.out.printf("Total miliseconds elapsed: %d\n", afterResponse - beforeExec); System.out.printf("Miliseconds spent generating requests: %d\n", afterExec - beforeExec);