本文整理汇总了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();
}
示例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;
}
示例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");
}
示例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);
}
}