本文整理汇总了Java中com.netflix.servo.monitor.BasicGauge类的典型用法代码示例。如果您正苦于以下问题:Java BasicGauge类的具体用法?Java BasicGauge怎么用?Java BasicGauge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicGauge类属于com.netflix.servo.monitor包,在下文中一共展示了BasicGauge类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RabbitMqTransport
import com.netflix.servo.monitor.BasicGauge; //导入依赖的package包/类
public RabbitMqTransport(
final Connection connection,
final Ref transportRef) throws IOException {
this.transportRef = new RabbitMqTransportRef(transportRef);
this.consumers = Lists.newArrayList();
final Counter deliveryCount = new BasicCounter(
MonitorConfig.builder("deliveryCount").withTag(
"transport",
getRef().toString()).build());
final Counter deliveryFailureCount = new BasicCounter(
MonitorConfig.builder("deliveryFailureCount").withTag(
"transport",
getRef().toString()).build());
DefaultMonitorRegistry.getInstance().register(deliveryCount);
DefaultMonitorRegistry.getInstance().register(deliveryFailureCount);
final MonitorConfig consumersSizeMonitorConfig = MonitorConfig.builder("consumers")
.withTag("transport", getRef().toString())
.build();
DefaultMonitorRegistry.getInstance().register(
new BasicGauge<>(
consumersSizeMonitorConfig,
new CollectionSizeCallable(this.consumers)));
final Channel channel = connection.createChannel();
final AMQP.Queue.DeclareOk queueDecl = channel.queueDeclare();
LOGGER.info("queue declared: {}", queueDecl);
final AMQP.Exchange.DeclareOk exchangeDeclOk = channel.exchangeDeclare(
this.transportRef.getExchange(),
this.transportRef.getType(),
true,
true,
Maps.<String, Object>newHashMap());
LOGGER.info("exchange declared: {}", exchangeDeclOk);
final AMQP.Queue.BindOk queueBindOk = channel.queueBind(
queueDecl.getQueue(),
this.transportRef.getExchange(),
"fanout".equals(this.transportRef.getType()) ? "" : this.transportRef.getRoutingKey());
LOGGER.info("queue binding declared: {}", queueBindOk);
final String consumerTag = channel.basicConsume(
queueDecl.getQueue(),
true,
new RabbitMqMessageConsumer(consumers, deliveryCount, deliveryFailureCount));
LOGGER.info("Received consumer tag {}", consumerTag);
}
示例2: gauge
import com.netflix.servo.monitor.BasicGauge; //导入依赖的package包/类
public static <T extends Number> Gauge<T> gauge(final String id, final Callable<T> callable) {
return new BasicGauge<>(MonitorConfig.builder(id).build(), callable);
}