Skip to content

Commit

Permalink
Ensure the default MetricWriter in Java 7 is not used in exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyer authored and wilkinsona committed May 13, 2015
1 parent 0bd845d commit 2aaf556
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

package org.springframework.boot.actuate.autoconfigure;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.boot.actuate.metrics.GaugeService;
import org.springframework.boot.actuate.metrics.buffer.BufferCounterService;
Expand Down Expand Up @@ -170,11 +172,20 @@ static class DefaultMetricsExporterConfiguration {
@Autowired(required = false)
private List<MetricWriter> writers;

@Autowired(required = false)
@Qualifier("actuatorMetricRepository")
private MetricWriter actuatorMetricRepository;

@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(MetricWriter.class)
public MetricCopyExporter messageChannelMetricExporter(MetricReader reader) {
return new MetricCopyExporter(reader, new CompositeMetricWriter(this.writers)) {
List<MetricWriter> writers = new ArrayList<MetricWriter>(this.writers);
if (this.actuatorMetricRepository != null
&& writers.contains(this.actuatorMetricRepository)) {
writers.remove(this.actuatorMetricRepository);
}
return new MetricCopyExporter(reader, new CompositeMetricWriter(writers)) {
@Scheduled(fixedDelayString = "${spring.metrics.export.delayMillis:5000}")
@Override
public void export() {
Expand Down

0 comments on commit 2aaf556

Please sign in to comment.