当前位置: 首页>>代码示例>>Java>>正文


Java SharedMetricRegistries.add方法代码示例

本文整理汇总了Java中com.codahale.metrics.SharedMetricRegistries.add方法的典型用法代码示例。如果您正苦于以下问题:Java SharedMetricRegistries.add方法的具体用法?Java SharedMetricRegistries.add怎么用?Java SharedMetricRegistries.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.codahale.metrics.SharedMetricRegistries的用法示例。


在下文中一共展示了SharedMetricRegistries.add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: vertxMetricsOptions

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@Bean
@ConditionalOnProperty(prefix = "hono.metric", name = "vertx", havingValue = "true")
public MetricsOptions vertxMetricsOptions() {
    LOG.info("metrics - vertx activated");
    SharedMetricRegistries.add(HONO, metricRegistry);
    SharedMetricRegistries.setDefault(HONO, metricRegistry);
    return new DropwizardMetricsOptions().setEnabled(true).setRegistryName(HONO)
            .setBaseName(prefix + ".vertx").setJmxEnabled(true);
}
 
开发者ID:eclipse,项目名称:hono,代码行数:10,代码来源:MetricConfig.java

示例2: run

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@Override
public void run(final DropwizardReporterExampleConfiguration configuration,
                final Environment environment) {

    // The default shared registry will be pre-registered in Dropwizard 1.0+
    SharedMetricRegistries.add("default", environment.metrics());

    final ExecutorService executorService = environment
            .lifecycle()
            .executorService("kafka-threads")
            .minThreads(2)
            .maxThreads(10)
            .build();

    executorService.execute(new Runnable() {
        @Override
        public void run() {
            final Producer<String, String> producer = new KafkaProducer<>(configuration.getProducer());
            int i = 0;
            try {
                while (true) {
                    String s = Integer.toString(i);
                    producer.send(new ProducerRecord<String, String>("my-topic", s, s));
                    i++;
                    Thread.sleep(500);
                }
            } catch (InterruptedException e) {
                LOGGER.info("Producer interrupted");
                producer.close();
            }
        }
    });

    executorService.execute(new Runnable() {
        @Override
        public void run() {
            final Consumer<String, String> consumer = new KafkaConsumer<>(configuration.getConsumer());
            consumer.subscribe(Arrays.asList("my-topic"));
            while (true) {
                ConsumerRecords<String, String> records = consumer.poll(2000);
                for (ConsumerRecord<String, String> record : records)
                    LOGGER.info("offset = {}, key = {}, value = {}", record.offset(), record.key(), record.value());
            }
        }
    });

}
 
开发者ID:SimpleFinance,项目名称:kafka-dropwizard-reporter,代码行数:48,代码来源:DropwizardReporterExampleApplication.java


注:本文中的com.codahale.metrics.SharedMetricRegistries.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。