use of org.springframework.boot.actuate.metrics.reader.MetricReader in project spring-boot by spring-projects.
the class MetricExportAutoConfiguration method metricWritersMetricExporter.
@Bean
@ConditionalOnMissingBean(name = "metricWritersMetricExporter")
public SchedulingConfigurer metricWritersMetricExporter(MetricExportProperties properties) {
Map<String, GaugeWriter> writers = new HashMap<>();
MetricReader reader = this.endpointReader;
if (reader == null && !CollectionUtils.isEmpty(this.readers)) {
reader = new CompositeMetricReader(this.readers.toArray(new MetricReader[this.readers.size()]));
}
if (reader == null && CollectionUtils.isEmpty(this.exporters)) {
return new NoOpSchedulingConfigurer();
}
MetricExporters exporters = new MetricExporters(properties);
if (reader != null) {
if (!CollectionUtils.isEmpty(this.writers)) {
writers.putAll(this.writers);
}
exporters.setReader(reader);
exporters.setWriters(writers);
}
exporters.setExporters(this.exporters == null ? Collections.<String, Exporter>emptyMap() : this.exporters);
return exporters;
}
use of org.springframework.boot.actuate.metrics.reader.MetricReader in project spring-boot by spring-projects.
the class MetricRepositoryAutoConfigurationTests method createServices.
@Test
public void createServices() throws Exception {
this.context = new AnnotationConfigApplicationContext(MetricRepositoryAutoConfiguration.class);
GaugeService gaugeService = this.context.getBean(BufferGaugeService.class);
assertThat(gaugeService).isNotNull();
assertThat(this.context.getBean(BufferCounterService.class)).isNotNull();
assertThat(this.context.getBean(PrefixMetricReader.class)).isNotNull();
gaugeService.submit("foo", 2.7);
MetricReader bean = this.context.getBean(MetricReader.class);
assertThat(bean.findOne("gauge.foo").getValue()).isEqualTo(2.7);
}
use of org.springframework.boot.actuate.metrics.reader.MetricReader in project spring-boot by spring-projects.
the class MetricReaderPublicMetricsTests method exposesMetrics.
@Test
public void exposesMetrics() {
List<Metric<?>> metrics = new ArrayList<>();
metrics.add(mock(Metric.class));
metrics.add(mock(Metric.class));
MetricReader reader = mock(MetricReader.class);
given(reader.findAll()).willReturn(metrics);
MetricReaderPublicMetrics publicMetrics = new MetricReaderPublicMetrics(reader);
assertThat(publicMetrics.metrics()).isEqualTo(metrics);
}
Aggregations