當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicGauge類代碼示例

本文整理匯總了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);
}
 
開發者ID:ngerakines,項目名稱:elasticservices,代碼行數:51,代碼來源:RabbitMqTransport.java

示例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);
}
 
開發者ID:ngerakines,項目名稱:elasticservices,代碼行數:4,代碼來源:Gauges.java


注:本文中的com.netflix.servo.monitor.BasicGauge類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。