本文整理匯總了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);
}