當前位置: 首頁>>代碼示例>>Java>>正文


Java ConsoleReporter類代碼示例

本文整理匯總了Java中com.codahale.metrics.ConsoleReporter的典型用法代碼示例。如果您正苦於以下問題:Java ConsoleReporter類的具體用法?Java ConsoleReporter怎麽用?Java ConsoleReporter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ConsoleReporter類屬於com.codahale.metrics包,在下文中一共展示了ConsoleReporter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startReporter

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
/**
 * Start metrics reporter.
 *
 */
protected void startReporter() {
  switch (cxt.conf.reporter) {
    case "console":
      consoleReporter = ConsoleReporter.forRegistry(cxt.register)
                            .convertRatesTo(TimeUnit.SECONDS)
                            .convertDurationsTo(TimeUnit.MILLISECONDS)
                            .build();
      consoleReporter.start(cxt.conf.report_interval, TimeUnit.SECONDS);
      break;
    case "jmx":
      jmxReporter = JmxReporter.forRegistry(cxt.register).build();
      jmxReporter.start();
      break;
    default:
      break;
  }
}
 
開發者ID:HashDataInc,項目名稱:bireme,代碼行數:22,代碼來源:Bireme.java

示例2: main

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
public static void main(String... args) {

        MetricRegistry metricRegistry = new MetricRegistry();

        final ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS).build();

        GitHub github = Feign.builder().invocationHandlerFactory(
                new FeignOutboundMetricsDecorator(new InvocationHandlerFactory.Default(), metricRegistry))
                .decoder(new GsonDecoder()).target(GitHub.class, "https://api.github.com");

        // Fetch and print a list of the contributors to this library.
        List<Contributor> contributors = github.contributors("mwiede", "metrics-feign");
        for (Contributor contributor : contributors) {
            System.out.println(contributor.login + " (" + contributor.contributions + ")");
        }

        reporter.report();
    }
 
開發者ID:mwiede,項目名稱:metrics-feign,代碼行數:20,代碼來源:Example.java

示例3: run

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
private void run(PrintStream printStream) {
    long sleepPeriodMillis = config.getMetricsOutputPeriodSeconds() * 1000;
    ConsoleReporter consoleReporter = ConsoleReporter
            .forRegistry(metricRegistry)
            .outputTo(printStream)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
    while (true) {
        try {
            Thread.sleep(sleepPeriodMillis);
            consoleReporter.report();
        } catch (InterruptedException ignored) {
            interrupt();
            LOGGER.trace("interrupted");
            break;
        }
    }
}
 
開發者ID:vy,項目名稱:hrrs,代碼行數:20,代碼來源:MetricFileReporter.java

示例4: Migrator

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
/**
 * @param uri Uri where one instance of Grakn Engine is running
 * @param keyspace The {@link Keyspace} where the data should be persisted
 */
public Migrator(SimpleURI uri, Keyspace keyspace, int retries, boolean failFast, int maxDelayMs, int maxLines) {
    this.uri = uri;
    this.keyspace = keyspace;
    this.retries = retries;
    this.failFast = failFast;
    this.maxDelayMs = maxDelayMs;
    this.maxLines = maxLines;
    this.metricRegistry = new MetricRegistry();
    this.totalMeter = metricRegistry.meter(name(this.getClass(), "total"));
    this.successMeter = metricRegistry.meter(name(this.getClass(), "success"));
    this.parseTemplate = metricRegistry.timer(name(this.getClass(), "parse", "template"));
    this.reporter = ConsoleReporter.forRegistry(metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(MILLISECONDS)
            .build();
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:21,代碼來源:Migrator.java

示例5: addTimerForPdxTypeMetrics

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
public static void addTimerForPdxTypeMetrics(final ClientCache clientCache) {

        Region temp = clientCache.getRegion("PdxTypes");
        if (temp == null) {
            temp = clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY).create("PdxTypes");
        }
        final Region pdxRegions = temp;

        metricRegistry.register(MetricRegistry.name("PdxTypes", "count"),
                (Gauge<Integer>) () -> pdxRegions.keySetOnServer().size());

        ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry)
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .build();
        reporter.start(1, TimeUnit.MINUTES);
    }
 
開發者ID:charliemblack,項目名稱:gemfire-copy,代碼行數:18,代碼來源:ToolBox.java

示例6: main

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
public static void main(String[] args) throws InterruptedException {
    MemoryConsumer consumer = new MemoryConsumer();
    GcMonitor gcMonitor = GcMonitor.builder()
            .addRollingWindow("15min", Duration.ofMinutes(15))
            .build();
    gcMonitor.start();

    MetricRegistry registry = new MetricRegistry();
    registry.registerAll(DropwizardAdapter.toMetricSet("jvm-gc-monitor", gcMonitor));
    ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(registry).build();
    consoleReporter.start(10, TimeUnit.SECONDS);

    try {
        while (true) {
            consumer.consume(ThreadLocalRandom.current().nextInt(10) + 1,  1);
            consumer.consume(ThreadLocalRandom.current().nextInt(20) + 100,  1);
            TimeUnit.SECONDS.sleep(5);
        }
    } finally {
        consumer.close();
        gcMonitor.stop();
    }
}
 
開發者ID:vladimir-bukhtoyarov,項目名稱:gc-monitor,代碼行數:24,代碼來源:DropwizardMain.java

示例7: main

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
public static void main(String args[]) throws IOException, InterruptedException {
	ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics).convertRatesTo(TimeUnit.SECONDS)
			.convertDurationsTo(TimeUnit.MILLISECONDS).build();
	metrics.register("jvm.mem", new MemoryUsageGaugeSet());
	metrics.register("jvm.gc", new GarbageCollectorMetricSet());
	reporter.start(5, TimeUnit.SECONDS);

	String hostName = "192.168.66.29";
	ZabbixSender zabbixSender = new ZabbixSender("192.168.90.102", 10051);
	ZabbixReporter zabbixReporter = ZabbixReporter.forRegistry(metrics).hostName(hostName).prefix("test.")
			.build(zabbixSender);

	zabbixReporter.start(1, TimeUnit.SECONDS);

	TimeUnit.SECONDS.sleep(500);
}
 
開發者ID:hengyunabc,項目名稱:metrics-zabbix,代碼行數:17,代碼來源:GetStarted.java

示例8: run

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
@Override
public void run(ExampleConfiguration configuration, Environment environment) throws Exception {

    if(configuration.metricsEnabled()) {


        final Graphite graphite = new Graphite(new InetSocketAddress("graphite.example.com", 2003));

        final GraphiteReporter reporter = GraphiteReporter.forRegistry(environment.metrics())
                .prefixedWith("prefix")
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .filter(MetricFilter.ALL)
                .build(graphite);
        reporter.start(5, TimeUnit.SECONDS);

        final ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(environment.metrics()).build();
        consoleReporter.start(5, TimeUnit.SECONDS);
    }

    final ExampleResource exampleResource = new ExampleResource(environment.metrics());
    environment.jersey().register(exampleResource);
}
 
開發者ID:pims,項目名稱:dropwizard-metrics-example,代碼行數:24,代碼來源:ExampleApplication.java

示例9: startReporting

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
public void startReporting() {
    if (reporterName.equalsIgnoreCase("console")) {
        reporter = ConsoleReporter.forRegistry(metricRegistry)
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .build();
        ((ConsoleReporter) reporter).start(interval, TimeUnit.SECONDS);
    } else if (reporterName.equalsIgnoreCase("jmx")) {
        reporter = JmxReporter.forRegistry(metricRegistry)
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .build();
        ((JmxReporter) reporter).start();
    } else {
        throw new UnsupportedOperationException("Only 'ConsoleReporter' and 'JmxReporter' is supported, Reporter " +
                "type '" + reporter.getClass().getName() + "' is not supported");
    }
}
 
開發者ID:wso2,項目名稱:siddhi,代碼行數:19,代碼來源:SiddhiStatisticsManager.java

示例10: configureReporters

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
@Override
    public void configureReporters(MetricRegistry metricRegistry) {
        ConsoleReporter
            .forRegistry(metricRegistry)
            .build()
            .start(1, TimeUnit.MINUTES);
        
        
//        final Graphite graphite = new Graphite(new InetSocketAddress("graphite.example.com", 2003));
//        final GraphiteReporter reporter = GraphiteReporter.forRegistry(registry)
//                                                          .prefixedWith("web1.example.com")
//                                                          .convertRatesTo(TimeUnit.SECONDS)
//                                                          .convertDurationsTo(TimeUnit.MILLISECONDS)
//                                                          .filter(MetricFilter.ALL)
//                                                          .build(graphite);
//        reporter.start(1, TimeUnit.MINUTES);
    }
 
開發者ID:pgkaila,項目名稱:Metrics-POC,代碼行數:18,代碼來源:SpringConfiguringClass.java

示例11: testRegister

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
@Test
@Ignore("ad-hoc")
public void testRegister() throws Exception {
    // reporterAgent.allowedBeans= new ImmutableMap.Builder<String, String>().put("java.lang:type=Memory.HeapMemoryUsage","sssswww").build();
    String file = this.getClass().getResource("/test2.json").getFile();

    reporterAgent.readConfig(file);
    reporterAgent.initLogger();
    reporterAgent.registerPlatformBeans();

    reporterAgent.addBeanNotificationListener();
    ConsoleReporter reporter= ConsoleReporter.forRegistry(reporterAgent.metricRegistry)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
    reporter.start(1, TimeUnit.SECONDS);
    while(true) {
        // eat some memory
        String s = "";
        for (int i = 0; i < 100000; i++) {
             s+="asdasdasd";
        }
    }
}
 
開發者ID:mojn,項目名稱:jmx-cloudwatch-reporter,代碼行數:25,代碼來源:ReporterAgentTest.java

示例12: register

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
@Test
public void register() throws Exception {
  new MockUnit(MetricRegistry.class, Metric.class, Reporter.class, ConsoleReporter.class)
      .expect(unit -> {
        MetricRegistry registry = unit.get(MetricRegistry.class);

        expect(registry.register("m", unit.get(Metric.class)))
            .andReturn(unit.get(Metric.class));
      })
      .expect(unit -> {
        unit.get(ConsoleReporter.class).close();
      })
      .run(unit -> {
        Map<String, Metric> metrics = ImmutableMap.of("m", unit.get(Metric.class));
        Set<Reporter> reporters = ImmutableSet.of(unit.get(Reporter.class),
            unit.get(ConsoleReporter.class));
        MetricRegistryInitializer mri = new MetricRegistryInitializer(
            unit.get(MetricRegistry.class), metrics, reporters);
        mri.close();
      });
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:22,代碼來源:MetricRegistryInitializerTest.java

示例13: closeWithError

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
@Test
public void closeWithError() throws Exception {
  new MockUnit(MetricRegistry.class, Metric.class, Reporter.class, ConsoleReporter.class)
      .expect(unit -> {
        MetricRegistry registry = unit.get(MetricRegistry.class);

        expect(registry.register("m", unit.get(Metric.class)))
            .andReturn(unit.get(Metric.class));
      })
      .expect(unit -> {
        unit.get(ConsoleReporter.class).close();
        expectLastCall().andThrow(new IllegalStateException("intentional err"));
      })
      .run(unit -> {
        Map<String, Metric> metrics = ImmutableMap.of("m", unit.get(Metric.class));
        Set<Reporter> reporters = ImmutableSet.of(unit.get(Reporter.class),
            unit.get(ConsoleReporter.class));
        MetricRegistryInitializer mri = new MetricRegistryInitializer(
            unit.get(MetricRegistry.class), metrics, reporters);
        mri.close();
      });
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:23,代碼來源:MetricRegistryInitializerTest.java

示例14: main

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    MetricRegistry metrics = new MetricRegistry();
    ConsoleReporter reporter = PerformanceHelper.consoleReporter(metrics);
    Timer timer = metrics.timer("allocations");

    Random random = new Random(System.nanoTime());
    int iterations = 1000000;
    MemoryPointer[] pointerArray = new MemoryPointer[iterations];

    for (int i = 0; i < pointerArray.length; i++) {
        Timer.Context watch = timer.time();
        pointerArray[i] = MemoryAllocator.allocate(random.nextInt(16384));
        watch.stop();
    }

    reporter.report();
}
 
開發者ID:jordw,項目名稱:heftydb,代碼行數:18,代碼來源:MemoryPerformance.java

示例15: main

import com.codahale.metrics.ConsoleReporter; //導入依賴的package包/類
public static void main(String[] args) {
    MetricRegistry metrics = new MetricRegistry();
    ConsoleReporter reporter = PerformanceHelper.consoleReporter(metrics);
    Timer timer = metrics.timer("reads");
    TupleGenerator generator = new TupleGenerator();
    List<Tuple> tuples = generator.testRecords(1, 64000, 20, 16, 100);

    TupleBlock.Builder blockBuilder = new TupleBlock.Builder();
    for (Tuple tuple : tuples) {
        blockBuilder.addRecord(tuple);
    }

    TupleBlock block = blockBuilder.build();

    Random random = new Random(System.nanoTime());
    int iterations = 10000000;

    for (int i = 0; i < iterations; i++) {
        Timer.Context watch = timer.time();
        block.get(tuples.get(random.nextInt(tuples.size())).key());
        watch.stop();
    }

    reporter.report();
}
 
開發者ID:jordw,項目名稱:heftydb,代碼行數:26,代碼來源:RecordBlockPerformance.java


注:本文中的com.codahale.metrics.ConsoleReporter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。