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 pravega by pravega.
the class StatsProviderTest method testStatsProviderStartWithoutExporting.
@Test
public void testStatsProviderStartWithoutExporting() {
MetricsConfig appConfig = MetricsConfig.builder().with(MetricsConfig.ENABLE_STATISTICS, true).with(MetricsConfig.ENABLE_STATSD_REPORTER, true).with(MetricsConfig.ENABLE_INFLUXDB_REPORTER, true).build();
@Cleanup CompositeMeterRegistry localRegistry = new CompositeMeterRegistry();
@Cleanup StatsProvider statsProvider = new StatsProviderImpl(appConfig, localRegistry);
statsProvider.startWithoutExporting();
for (MeterRegistry registry : localRegistry.getRegistries()) {
assertTrue(registry instanceof SimpleMeterRegistry);
assertFalse(registry instanceof InfluxMeterRegistry);
assertFalse(registry instanceof StatsdMeterRegistry);
}
statsProvider.close();
assertTrue(0 == localRegistry.getRegistries().size());
}
use of io.micrometer.core.instrument.MeterRegistry in project pravega by pravega.
the class StatsProviderImpl method close.
@Synchronized
@Override
public void close() {
this.prometheusRegistry = null;
for (MeterRegistry registry : new ArrayList<MeterRegistry>(metrics.getRegistries())) {
registry.close();
metrics.remove(registry);
}
}
use of io.micrometer.core.instrument.MeterRegistry in project pravega by pravega.
the class StatsProviderImpl method startWithoutExporting.
@Synchronized
@Override
public void startWithoutExporting() {
this.prometheusRegistry = null;
for (MeterRegistry registry : new ArrayList<MeterRegistry>(metrics.getRegistries())) {
metrics.remove(registry);
}
Metrics.addRegistry(new SimpleMeterRegistry());
init();
}
use of io.micrometer.core.instrument.MeterRegistry in project spring-boot by spring-projects.
the class RestTemplateMetricsConfigurationTests method afterMaxUrisReachedFurtherUrisAreDenied.
@Test
void afterMaxUrisReachedFurtherUrisAreDenied(CapturedOutput output) {
this.contextRunner.withPropertyValues("management.metrics.web.client.max-uri-tags=2").run((context) -> {
MeterRegistry registry = getInitializedMeterRegistry(context);
assertThat(registry.get("http.client.requests").meters()).hasSize(2);
assertThat(output).contains("Reached the maximum number of URI tags for 'http.client.requests'.").contains("Are you using 'uriVariables'?");
});
}
Aggregations