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


Java MetricsRegistry.newCounter方法代码示例

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


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

示例1: testTopicReporter

import com.yammer.metrics.core.MetricsRegistry; //导入方法依赖的package包/类
@Test
public void testTopicReporter() {
    MetricsRegistry registry = new MetricsRegistry();
    Counter counter = registry.newCounter(KafkaReporterTest.class, "test-counter");
    counter.inc();

    Properties producerProps = new Properties();
    producerProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaConnect);
    producerProps.put("schema.registry.url", schemaRegistry);

    KafkaReporter reporter = new KafkaReporter(registry, producerProps, topic);
    reporter.start(1, TimeUnit.SECONDS);

    Properties props = new Properties();
    props.put("zookeeper.connect", zkConnect);
    props.put("group.id", UUID.randomUUID().toString());
    props.put("auto.offset.reset", "smallest");
    props.put("zookeeper.session.timeout.ms", "30000");
    props.put("consumer.timeout.ms", "30000");
    props.put("schema.registry.url", schemaRegistry);

    ConsumerConnector consumer = Consumer.createJavaConsumerConnector(new ConsumerConfig(props));
    KafkaStream<String, Object> messageStream = consumer.createMessageStreamsByFilter(new Whitelist(topic),
            1,
            new StringDecoder(null),
            new KafkaAvroDecoder(new VerifiableProperties(props))).get(0);

    GenericRecord message = (GenericRecord) messageStream.iterator().next().message();
    assertNotNull(message);

    reporter.shutdown();
}
 
开发者ID:elodina,项目名称:java-kafka,代码行数:33,代码来源:KafkaReporterTest.java

示例2: getCounter

import com.yammer.metrics.core.MetricsRegistry; //导入方法依赖的package包/类
private static Counter getCounter(MetricsRegistry metricsRegistry,
                                  MetricMetadata metricMetadata) {
    Counter counter = metricsRegistry.newCounter(YammerExample.class, "yammer.test.counter");
    metricMetadata.forMetric(counter)
            .withSourceName("signalFx")
            .withDimension(LIBRARY_VERSION, YAMMER);
    return counter;
}
 
开发者ID:signalfx,项目名称:signalfx-java,代码行数:9,代码来源:YammerExample.java

示例3: RunnerStats

import com.yammer.metrics.core.MetricsRegistry; //导入方法依赖的package包/类
public RunnerStats(MetricsRegistry registry) {
  this.normalRunners = registry.newCounter(MetricsConnection.class, "normalRunnersCount");
  this.delayRunners = registry.newCounter(MetricsConnection.class, "delayRunnersCount");
  this.delayIntevalHist = registry.newHistogram(MetricsConnection.class, "delayIntervalHist");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:6,代码来源:MetricsConnection.java

示例4: newCounter

import com.yammer.metrics.core.MetricsRegistry; //导入方法依赖的package包/类
/**
 *
 * Return an existing counter if
 *  (a) A counter already exist with the same metric name.
 * Otherwise, creates a new meter and registers
 *
 * @param registry MetricsRegistry
 * @param name metric name
 * @return Counter
 */
public static Counter newCounter(MetricsRegistry registry, MetricName name) {
  if (registry != null) {
    return registry.newCounter(name);
  } else {
    return Metrics.newCounter(name);
  }
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:18,代码来源:MetricsHelper.java


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