use of org.springframework.boot.actuate.metrics.writer.MetricWriter in project spring-boot by spring-projects.
the class MetricExportAutoConfigurationTests method provideAdditionalWriter.
@Test
public void provideAdditionalWriter() {
this.context = new AnnotationConfigApplicationContext(WriterConfig.class, MetricRepositoryAutoConfiguration.class, MetricExportAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
GaugeService gaugeService = this.context.getBean(GaugeService.class);
assertThat(gaugeService).isNotNull();
gaugeService.submit("foo", 2.7);
MetricExporters exporters = this.context.getBean(MetricExporters.class);
MetricCopyExporter exporter = (MetricCopyExporter) exporters.getExporters().get("writer");
exporter.setIgnoreTimestamps(true);
exporter.export();
MetricWriter writer = this.context.getBean("writer", MetricWriter.class);
Mockito.verify(writer, Mockito.atLeastOnce()).set(any(Metric.class));
}
use of org.springframework.boot.actuate.metrics.writer.MetricWriter in project spring-boot by spring-projects.
the class MetricExportAutoConfigurationTests method metricsFlushAutomatically.
@Test
public void metricsFlushAutomatically() throws Exception {
this.context = new AnnotationConfigApplicationContext(WriterConfig.class, MetricRepositoryAutoConfiguration.class, MetricExportAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
GaugeService gaugeService = this.context.getBean(GaugeService.class);
assertThat(gaugeService).isNotNull();
gaugeService.submit("foo", 2.7);
MetricExporters flusher = this.context.getBean(MetricExporters.class);
// this will be called by Spring on shutdown
flusher.close();
MetricWriter writer = this.context.getBean("writer", MetricWriter.class);
verify(writer, atLeastOnce()).set(any(Metric.class));
}
Aggregations