Search in sources :

Example 1 with CompositeMetricReader

use of org.springframework.boot.actuate.metrics.reader.CompositeMetricReader 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;
}
Also used : CompositeMetricReader(org.springframework.boot.actuate.metrics.reader.CompositeMetricReader) HashMap(java.util.HashMap) GaugeWriter(org.springframework.boot.actuate.metrics.writer.GaugeWriter) CompositeMetricReader(org.springframework.boot.actuate.metrics.reader.CompositeMetricReader) MetricReader(org.springframework.boot.actuate.metrics.reader.MetricReader) MetricsEndpointMetricReader(org.springframework.boot.actuate.endpoint.MetricsEndpointMetricReader) Exporter(org.springframework.boot.actuate.metrics.export.Exporter) MetricExporters(org.springframework.boot.actuate.metrics.export.MetricExporters) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

HashMap (java.util.HashMap)1 MetricsEndpointMetricReader (org.springframework.boot.actuate.endpoint.MetricsEndpointMetricReader)1 Exporter (org.springframework.boot.actuate.metrics.export.Exporter)1 MetricExporters (org.springframework.boot.actuate.metrics.export.MetricExporters)1 CompositeMetricReader (org.springframework.boot.actuate.metrics.reader.CompositeMetricReader)1 MetricReader (org.springframework.boot.actuate.metrics.reader.MetricReader)1 GaugeWriter (org.springframework.boot.actuate.metrics.writer.GaugeWriter)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1