Package com.codahale.metrics

Examples of com.codahale.metrics.ConsoleReporter


    reporter.start(10, TimeUnit.SECONDS);
    return reporter;
  }

  private static ConsoleReporter startConsoleReporter(MetricRegistry registry) throws Exception {
    final ConsoleReporter reporter = ConsoleReporter
        .forRegistry(registry)
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS)
        .build();
    reporter.start(1, TimeUnit.MINUTES);
    return reporter;
  }
View Full Code Here


     * The scheduling is done based on intervalType please review the
     * simulation plan for the timing.
     */
    private void runThreadedSimulation(SimulationPlan plan) {
        this.initializeMetricsServer(plan);
        final ConsoleReporter consoleReporter = createConsoleReporter(metrics, plan.getMetricsReportInterval());

        final ScheduledExecutorService aggregators = Executors.newScheduledThreadPool(1, new SimulatorThreadFactory());
        final ScheduledExecutorService collectors = Executors.newScheduledThreadPool(
            plan.getNumMeasurementCollectors(), new SimulatorThreadFactory());
        final ExecutorService aggregationQueue = Executors.newSingleThreadExecutor(new SimulatorThreadFactory());
        final ScheduledExecutorService readers = Executors.newScheduledThreadPool(plan.getReaderThreadPoolSize(),
            new SimulatorThreadFactory());

        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                shutdown(collectors, "collectors", 5);
                shutdown(readers, "readers", 5);
                shutdown(aggregators, "aggregators", 1);
                shutdown(aggregationQueue, "aggregationQueue", Integer.MAX_VALUE);
                metricsServer.shutdown();
                log.info("Wait for console reporter...");
                try {
                    Thread.sleep(181000);
                } catch (InterruptedException e) {
                }
                consoleReporter.stop();
            }
        });

        MeasurementAggregator measurementAggregator = new MeasurementAggregator(metricsServer, this, metrics,
            aggregationQueue, plan.getNumMeasurementCollectors() * plan.getBatchSize());
 
View Full Code Here

    private ConsoleReporter createConsoleReporter(Metrics metrics, int reportInterval) {
        try {
            File basedir = new File(System.getProperty("rhq.metrics.simulator.basedir"));
            File logDir = new File(basedir, "log");
            ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(metrics.registry)
                .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS)
                .outputTo(new PrintStream(new FileOutputStream(new File(logDir, "metrics.txt")))).build();
            consoleReporter.start(reportInterval, TimeUnit.SECONDS);
            return consoleReporter;
        } catch (FileNotFoundException e) {
            throw new RuntimeException("Failed to create console reporter", e);
        }
    }
View Full Code Here

    this.launchConfig = launchConfig;
  }

  @Override
  public ConsoleReporter get() {
    ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry).build();
    String interval = launchConfig.getOther("metrics.scheduledreporter.interval", "30");
    reporter.start(Long.parseLong(interval), TimeUnit.SECONDS);
    return reporter;
  }
View Full Code Here

        // Capture Stats ...

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        final ConsoleReporter reporter = ConsoleReporter.forRegistry(cmm.getMetrics())
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.SECONDS)
                .outputTo(new PrintStream(baos))
                .build();
        reporter.start(1, TimeUnit.SECONDS);
        try {
            Thread.sleep(1800);
        } catch (InterruptedException e) {
        }

        reporter.stop();

        // ... for assertion

        String result = baos.toString().replace("= 0.48 calls", "= 0.50 calls").replace("= 0.49 calls", "= 0.50 calls");
        result = result.substring(result.indexOf("-- Timers"));
View Full Code Here

        // Capture Stats ...

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        final ConsoleReporter reporter = ConsoleReporter.forRegistry(cmm.getMetrics())
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.SECONDS)
                .outputTo(new PrintStream(baos))
                .build();
        reporter.start(1, TimeUnit.SECONDS);
        try {
            Thread.sleep(1800);
        } catch (InterruptedException e) {
        }

        reporter.stop();

        // ... for assertion

        String result = baos.toString()
                .replace("= 0.47 calls", "= 0.50 calls")
View Full Code Here

    @Override
    public void testRunFinished(Result result) throws Exception {
        super.testRunFinished(result);

        final ConsoleReporter reporter = ConsoleReporter.forRegistry(codahaleMetricsMonitor.getMetrics())
                .convertRatesTo(TimeUnit.MILLISECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .outputTo(System.out)
                .build();

        reporter.report();

    }
View Full Code Here

        }
      }
    });

    Metrics.getMetrics().registerAll(Metrics.getJstack());
    final ConsoleReporter reporter = ConsoleReporter
        .forRegistry(Metrics.getMetrics())
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS).build();
    reporter.start(1, TimeUnit.MINUTES);

    thread.start();
  }
View Full Code Here

TOP

Related Classes of com.codahale.metrics.ConsoleReporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.