Search in sources :

Example 1 with DropwizardMetricServices

use of org.springframework.boot.actuate.metrics.dropwizard.DropwizardMetricServices in project spring-boot by spring-projects.

the class MetricRepositoryAutoConfigurationTests method dropwizardInstalledIfPresent.

@Test
public void dropwizardInstalledIfPresent() {
    this.context = new AnnotationConfigApplicationContext(MetricsDropwizardAutoConfiguration.class, MetricRepositoryAutoConfiguration.class, AopAutoConfiguration.class);
    GaugeService gaugeService = this.context.getBean(GaugeService.class);
    assertThat(gaugeService).isNotNull();
    gaugeService.submit("foo", 2.7);
    DropwizardMetricServices exporter = this.context.getBean(DropwizardMetricServices.class);
    assertThat(exporter).isEqualTo(gaugeService);
    MetricRegistry registry = this.context.getBean(MetricRegistry.class);
    @SuppressWarnings("unchecked") Gauge<Double> gauge = (Gauge<Double>) registry.getMetrics().get("gauge.foo");
    assertThat(gauge.getValue()).isEqualTo(new Double(2.7));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) BufferGaugeService(org.springframework.boot.actuate.metrics.buffer.BufferGaugeService) GaugeService(org.springframework.boot.actuate.metrics.GaugeService) MetricRegistry(com.codahale.metrics.MetricRegistry) AopAutoConfiguration(org.springframework.boot.autoconfigure.aop.AopAutoConfiguration) DropwizardMetricServices(org.springframework.boot.actuate.metrics.dropwizard.DropwizardMetricServices) Gauge(com.codahale.metrics.Gauge) Test(org.junit.Test)

Example 2 with DropwizardMetricServices

use of org.springframework.boot.actuate.metrics.dropwizard.DropwizardMetricServices in project spring-boot by spring-projects.

the class MetricsDropwizardAutoConfigurationTests method dropwizardWithoutCustomReservoirConfigured.

@Test
public void dropwizardWithoutCustomReservoirConfigured() {
    this.context = new AnnotationConfigApplicationContext(MetricsDropwizardAutoConfiguration.class);
    DropwizardMetricServices dropwizardMetricServices = this.context.getBean(DropwizardMetricServices.class);
    ReservoirFactory reservoirFactory = (ReservoirFactory) ReflectionTestUtils.getField(dropwizardMetricServices, "reservoirFactory");
    assertThat(reservoirFactory.getReservoir("test")).isNull();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DropwizardMetricServices(org.springframework.boot.actuate.metrics.dropwizard.DropwizardMetricServices) ReservoirFactory(org.springframework.boot.actuate.metrics.dropwizard.ReservoirFactory) Test(org.junit.Test)

Example 3 with DropwizardMetricServices

use of org.springframework.boot.actuate.metrics.dropwizard.DropwizardMetricServices in project spring-boot by spring-projects.

the class MetricsDropwizardAutoConfigurationTests method dropwizardWithCustomReservoirConfigured.

@Test
public void dropwizardWithCustomReservoirConfigured() {
    this.context = new AnnotationConfigApplicationContext(MetricsDropwizardAutoConfiguration.class, Config.class);
    DropwizardMetricServices dropwizardMetricServices = this.context.getBean(DropwizardMetricServices.class);
    ReservoirFactory reservoirFactory = (ReservoirFactory) ReflectionTestUtils.getField(dropwizardMetricServices, "reservoirFactory");
    assertThat(reservoirFactory.getReservoir("test")).isInstanceOf(UniformReservoir.class);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DropwizardMetricServices(org.springframework.boot.actuate.metrics.dropwizard.DropwizardMetricServices) ReservoirFactory(org.springframework.boot.actuate.metrics.dropwizard.ReservoirFactory) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 DropwizardMetricServices (org.springframework.boot.actuate.metrics.dropwizard.DropwizardMetricServices)3 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 ReservoirFactory (org.springframework.boot.actuate.metrics.dropwizard.ReservoirFactory)2 Gauge (com.codahale.metrics.Gauge)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 GaugeService (org.springframework.boot.actuate.metrics.GaugeService)1 BufferGaugeService (org.springframework.boot.actuate.metrics.buffer.BufferGaugeService)1 AopAutoConfiguration (org.springframework.boot.autoconfigure.aop.AopAutoConfiguration)1