Search in sources :

Example 1 with StatsdMetricWriter

use of org.springframework.boot.actuate.metrics.statsd.StatsdMetricWriter in project spring-boot by spring-projects.

the class MetricExportAutoConfigurationTests method statsdWithHost.

@SuppressWarnings("unchecked")
@Test
public void statsdWithHost() throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "spring.metrics.export.statsd.host=localhost");
    this.context.register(MetricEndpointConfiguration.class, MetricExportAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    StatsdMetricWriter statsdWriter = this.context.getBean(StatsdMetricWriter.class);
    assertThat(statsdWriter).isNotNull();
    SchedulingConfigurer schedulingConfigurer = this.context.getBean(SchedulingConfigurer.class);
    Map<String, GaugeWriter> exporters = (Map<String, GaugeWriter>) ReflectionTestUtils.getField(schedulingConfigurer, "writers");
    assertThat(exporters).containsValue(statsdWriter);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) GaugeWriter(org.springframework.boot.actuate.metrics.writer.GaugeWriter) StatsdMetricWriter(org.springframework.boot.actuate.metrics.statsd.StatsdMetricWriter) Map(java.util.Map) SchedulingConfigurer(org.springframework.scheduling.annotation.SchedulingConfigurer) Test(org.junit.Test)

Aggregations

Map (java.util.Map)1 Test (org.junit.Test)1 StatsdMetricWriter (org.springframework.boot.actuate.metrics.statsd.StatsdMetricWriter)1 GaugeWriter (org.springframework.boot.actuate.metrics.writer.GaugeWriter)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 SchedulingConfigurer (org.springframework.scheduling.annotation.SchedulingConfigurer)1