use of io.micrometer.core.instrument.MeterRegistry in project vertx-micrometer-metrics by vert-x3.
the class GaugesTest method shouldIgnoreGaugeLabel.
@Test
public void shouldIgnoreGaugeLabel() {
MeterRegistry registry = new SimpleMeterRegistry();
BackendRegistries.registerMatchers(registry, Collections.singletonList(new Match().setLabel("address").setType(MatchType.REGEX).setValue(".*").setAlias("_")));
Gauges<LongAdder> gauges = new Gauges<>("my_gauge", "", LongAdder::new, LongAdder::doubleValue, registry, Label.ADDRESS);
gauges.get("addr1").increment();
gauges.get("addr1").increment();
gauges.get("addr2").increment();
Gauge g = registry.find("my_gauge").tags("address", "_").gauge();
assertThat(g.value()).isEqualTo(3d);
g = registry.find("my_gauge").tags("address", "addr1").gauge();
assertThat(g).isNull();
g = registry.find("my_gauge").tags("address", "addr2").gauge();
assertThat(g).isNull();
}
use of io.micrometer.core.instrument.MeterRegistry in project vertx-micrometer-metrics by vert-x3.
the class SummariesTest method shouldIgnoreSummaryLabel.
@Test
public void shouldIgnoreSummaryLabel() {
MeterRegistry registry = new SimpleMeterRegistry();
BackendRegistries.registerMatchers(registry, Collections.singletonList(new Match().setLabel("address").setType(MatchType.REGEX).setValue(".*").setAlias("_")));
Summaries summaries = new Summaries("my_summary", "", registry, Label.ADDRESS);
summaries.get("addr1").record(5);
summaries.get("addr1").record(8);
summaries.get("addr2").record(10);
DistributionSummary s = registry.find("my_summary").tags("address", "_").summary();
assertThat(s.count()).isEqualTo(3);
assertThat(s.totalAmount()).isEqualTo(23);
s = registry.find("my_summary").tags("address", "addr1").summary();
assertThat(s).isNull();
s = registry.find("my_summary").tags("address", "addr2").summary();
assertThat(s).isNull();
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-integration by spring-projects.
the class MicrometerMetricsTests method testSend.
@Test
public void testSend() {
GenericMessage<String> message = new GenericMessage<>("foo");
this.channel.send(message);
try {
this.channel.send(this.source.receive());
fail("Expected exception");
} catch (MessagingException e) {
assertThat(e.getCause().getMessage()).isEqualTo("testErrorCount");
}
this.channel2.send(message);
this.queue.send(message);
this.queue.send(message);
this.queue.receive();
this.badPoll.send(message);
try {
this.badPoll.receive();
fail("Expected exception");
} catch (RuntimeException e) {
assertThat(e.getMessage()).isEqualTo("badPoll");
}
nullChannel.send(message);
MeterRegistry registry = this.meterRegistry;
assertThat(registry.get("spring.integration.channels").gauge().value()).isEqualTo(6);
assertThat(registry.get("spring.integration.handlers").gauge().value()).isEqualTo(3);
assertThat(registry.get("spring.integration.sources").gauge().value()).isEqualTo(1);
assertThat(registry.get("spring.integration.receive").tag("name", "source").tag("result", "success").counter().count()).isEqualTo(1);
assertThat(registry.get("spring.integration.receive").tag("name", "badPoll").tag("result", "failure").counter().count()).isEqualTo(1);
assertThat(registry.get("spring.integration.send").tag("name", "eipBean.handler").tag("result", "success").timer().count()).isEqualTo(1);
assertThat(registry.get("spring.integration.send").tag("name", "eipMethod.handler").tag("result", "success").timer().count()).isEqualTo(1);
assertThat(registry.get("spring.integration.send").tag("name", "channel").tag("result", "success").timer().count()).isEqualTo(1);
assertThat(registry.get("spring.integration.send").tag("name", "channel").tag("result", "failure").timer().count()).isEqualTo(1);
assertThat(registry.get("spring.integration.send").tag("name", "eipMethod.handler").tag("result", "failure").timer().count()).isEqualTo(1);
assertThat(registry.get("spring.integration.receive").tag("name", "queue").tag("result", "success").counter().count()).isEqualTo(1);
assertThat(registry.get("spring.integration.send").tag("name", "nullChannel").tag("result", "success").timer().count()).isEqualTo(1);
BeanDefinitionRegistry beanFactory = (BeanDefinitionRegistry) this.context.getBeanFactory();
beanFactory.registerBeanDefinition("newChannel", BeanDefinitionBuilder.genericBeanDefinition(DirectChannel.class).getRawBeanDefinition());
DirectChannel newChannel = this.context.getBean("newChannel", DirectChannel.class);
newChannel.setBeanName("newChannel");
newChannel.subscribe(m -> {
});
newChannel.send(new GenericMessage<>("foo"));
assertThat(registry.get("spring.integration.send").tag("name", "newChannel").tag("result", "success").timer().count()).isEqualTo(1);
}
use of io.micrometer.core.instrument.MeterRegistry in project resilience4j by resilience4j.
the class BulkheadMetrics method bindTo.
@Override
public void bindTo(MeterRegistry registry) {
for (Bulkhead bulkhead : bulkheads) {
final String name = bulkhead.getName();
Gauge.builder(getName(prefix, name, AVAILABLE_CONCURRENT_CALLS), bulkhead, (cb) -> cb.getMetrics().getAvailableConcurrentCalls()).register(registry);
}
}
use of io.micrometer.core.instrument.MeterRegistry in project resilience4j by resilience4j.
the class CircuitBreakerMetrics method bindTo.
@Override
public void bindTo(MeterRegistry registry) {
for (CircuitBreaker circuitBreaker : circuitBreakers) {
final String name = circuitBreaker.getName();
Gauge.builder(getName(prefix, name, STATE), circuitBreaker, (cb) -> cb.getState().getOrder()).register(registry);
Gauge.builder(getName(prefix, name, BUFFERED_MAX), circuitBreaker, (cb) -> cb.getMetrics().getMaxNumberOfBufferedCalls()).register(registry);
Gauge.builder(getName(prefix, name, BUFFERED), circuitBreaker, (cb) -> cb.getMetrics().getNumberOfBufferedCalls()).register(registry);
Gauge.builder(getName(prefix, name, FAILED), circuitBreaker, (cb) -> cb.getMetrics().getNumberOfFailedCalls()).register(registry);
Gauge.builder(getName(prefix, name, NOT_PERMITTED), circuitBreaker, (cb) -> cb.getMetrics().getNumberOfNotPermittedCalls()).register(registry);
Gauge.builder(getName(prefix, name, SUCCESSFUL), circuitBreaker, (cb) -> cb.getMetrics().getNumberOfSuccessfulCalls()).register(registry);
}
}
Aggregations