当前位置: 首页>>代码示例>>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;未经允许,请勿转载。