Search in sources :

Example 1 with MetricCopyExporter

use of org.springframework.boot.actuate.metrics.export.MetricCopyExporter 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));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MetricCopyExporter(org.springframework.boot.actuate.metrics.export.MetricCopyExporter) GaugeService(org.springframework.boot.actuate.metrics.GaugeService) PropertyPlaceholderAutoConfiguration(org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration) StatsdMetricWriter(org.springframework.boot.actuate.metrics.statsd.StatsdMetricWriter) MetricWriter(org.springframework.boot.actuate.metrics.writer.MetricWriter) Metric(org.springframework.boot.actuate.metrics.Metric) MetricExporters(org.springframework.boot.actuate.metrics.export.MetricExporters) Test(org.junit.Test)

Example 2 with MetricCopyExporter

use of org.springframework.boot.actuate.metrics.export.MetricCopyExporter in project spring-boot by spring-projects.

the class MetricExportAutoConfigurationTests method exportMetricsEndpoint.

@Test
public void exportMetricsEndpoint() {
    this.context = new AnnotationConfigApplicationContext(WriterConfig.class, MetricEndpointConfiguration.class, MetricExportAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    MetricExporters exporters = this.context.getBean(MetricExporters.class);
    MetricCopyExporter exporter = (MetricCopyExporter) exporters.getExporters().get("writer");
    exporter.setIgnoreTimestamps(true);
    exporter.export();
    MetricsEndpointMetricReader reader = this.context.getBean("endpointReader", MetricsEndpointMetricReader.class);
    Mockito.verify(reader, Mockito.atLeastOnce()).findAll();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MetricCopyExporter(org.springframework.boot.actuate.metrics.export.MetricCopyExporter) MetricsEndpointMetricReader(org.springframework.boot.actuate.endpoint.MetricsEndpointMetricReader) PropertyPlaceholderAutoConfiguration(org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration) MetricExporters(org.springframework.boot.actuate.metrics.export.MetricExporters) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 MetricCopyExporter (org.springframework.boot.actuate.metrics.export.MetricCopyExporter)2 MetricExporters (org.springframework.boot.actuate.metrics.export.MetricExporters)2 PropertyPlaceholderAutoConfiguration (org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 MetricsEndpointMetricReader (org.springframework.boot.actuate.endpoint.MetricsEndpointMetricReader)1 GaugeService (org.springframework.boot.actuate.metrics.GaugeService)1 Metric (org.springframework.boot.actuate.metrics.Metric)1 StatsdMetricWriter (org.springframework.boot.actuate.metrics.statsd.StatsdMetricWriter)1 MetricWriter (org.springframework.boot.actuate.metrics.writer.MetricWriter)1