Merge pull request #12030 from jkschneider

* pr/12030:
  Fix upstream micrometer renames
pull/12032/merge
Phillip Webb 7 years ago
commit 94bbaa74e6

@ -24,7 +24,7 @@ import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.Meter.Id; import io.micrometer.core.instrument.Meter.Id;
import io.micrometer.core.instrument.config.MeterFilter; import io.micrometer.core.instrument.config.MeterFilter;
import io.micrometer.core.instrument.config.MeterFilterReply; import io.micrometer.core.instrument.config.MeterFilterReply;
import io.micrometer.core.instrument.histogram.HistogramConfig; import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties.Distribution; import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties.Distribution;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -55,8 +55,10 @@ public class PropertiesMeterFilter implements MeterFilter {
} }
@Override @Override
public HistogramConfig configure(Meter.Id id, HistogramConfig config) { public DistributionStatisticConfig configure(Meter.Id id,
HistogramConfig.Builder builder = HistogramConfig.builder(); DistributionStatisticConfig config) {
DistributionStatisticConfig.Builder builder = DistributionStatisticConfig
.builder();
Distribution distribution = this.properties.getDistribution(); Distribution distribution = this.properties.getDistribution();
builder.percentilesHistogram( builder.percentilesHistogram(
lookup(distribution.getPercentilesHistogram(), id, null)); lookup(distribution.getPercentilesHistogram(), id, null));

@ -22,7 +22,7 @@ import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.Meter.Id; import io.micrometer.core.instrument.Meter.Id;
import io.micrometer.core.instrument.Meter.Type; import io.micrometer.core.instrument.Meter.Type;
import io.micrometer.core.instrument.config.MeterFilterReply; import io.micrometer.core.instrument.config.MeterFilterReply;
import io.micrometer.core.instrument.histogram.HistogramConfig; import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
@ -50,7 +50,7 @@ public class PropertiesMeterFilterTests {
public ExpectedException thrown = ExpectedException.none(); public ExpectedException thrown = ExpectedException.none();
@Mock @Mock
private HistogramConfig config; private DistributionStatisticConfig config;
@Before @Before
public void setup() { public void setup() {
@ -139,32 +139,32 @@ public class PropertiesMeterFilterTests {
public void configureWhenHasHistogramTrueShouldSetPercentilesHistogramToTrue() { public void configureWhenHasHistogramTrueShouldSetPercentilesHistogramToTrue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.percentiles-histogram.spring.boot=true")); createProperties("distribution.percentiles-histogram.spring.boot=true"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.isPercentileHistogram()).isTrue(); DistributionStatisticConfig.DEFAULT).isPercentileHistogram()).isTrue();
} }
@Test @Test
public void configureWhenHasHistogramFalseShouldSetPercentilesHistogramToFalse() { public void configureWhenHasHistogramFalseShouldSetPercentilesHistogramToFalse() {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.percentiles-histogram.spring.boot=false")); createProperties("distribution.percentiles-histogram.spring.boot=false"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.isPercentileHistogram()).isFalse(); DistributionStatisticConfig.DEFAULT).isPercentileHistogram()).isFalse();
} }
@Test @Test
public void configureWhenHasHigherHistogramTrueShouldSetPercentilesHistogramToTrue() { public void configureWhenHasHigherHistogramTrueShouldSetPercentilesHistogramToTrue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.percentiles-histogram.spring=true")); createProperties("distribution.percentiles-histogram.spring=true"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.isPercentileHistogram()).isTrue(); DistributionStatisticConfig.DEFAULT).isPercentileHistogram()).isTrue();
} }
@Test @Test
public void configureWhenHasHigherHistogramFalseShouldSetPercentilesHistogramToFalse() { public void configureWhenHasHigherHistogramFalseShouldSetPercentilesHistogramToFalse() {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.percentiles-histogram.spring=false")); createProperties("distribution.percentiles-histogram.spring=false"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.isPercentileHistogram()).isFalse(); DistributionStatisticConfig.DEFAULT).isPercentileHistogram()).isFalse();
} }
@Test @Test
@ -172,8 +172,8 @@ public class PropertiesMeterFilterTests {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.percentiles-histogram.spring=true", createProperties("distribution.percentiles-histogram.spring=true",
"distribution.percentiles-histogram.spring.boot=false")); "distribution.percentiles-histogram.spring.boot=false"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.isPercentileHistogram()).isFalse(); DistributionStatisticConfig.DEFAULT).isPercentileHistogram()).isFalse();
} }
@Test @Test
@ -181,32 +181,34 @@ public class PropertiesMeterFilterTests {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.percentiles-histogram.spring=false", createProperties("distribution.percentiles-histogram.spring=false",
"distribution.percentiles-histogram.spring.boot=true")); "distribution.percentiles-histogram.spring.boot=true"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.isPercentileHistogram()).isTrue(); DistributionStatisticConfig.DEFAULT).isPercentileHistogram()).isTrue();
} }
@Test @Test
public void configureWhenAllHistogramTrueSetPercentilesHistogramToTrue() { public void configureWhenAllHistogramTrueSetPercentilesHistogramToTrue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.percentiles-histogram.all=true")); createProperties("distribution.percentiles-histogram.all=true"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.isPercentileHistogram()).isTrue(); DistributionStatisticConfig.DEFAULT).isPercentileHistogram()).isTrue();
} }
@Test @Test
public void configureWhenHasPercentilesShouldSetPercentilesToValue() { public void configureWhenHasPercentilesShouldSetPercentilesToValue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.percentiles.spring.boot=1,1.5,2")); createProperties("distribution.percentiles.spring.boot=1,1.5,2"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.getPercentiles()).containsExactly(1, 1.5, 2); DistributionStatisticConfig.DEFAULT).getPercentiles()).containsExactly(1,
1.5, 2);
} }
@Test @Test
public void configureWhenHasHigherPercentilesShouldSetPercentilesToValue() { public void configureWhenHasHigherPercentilesShouldSetPercentilesToValue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.percentiles.spring=1,1.5,2")); createProperties("distribution.percentiles.spring=1,1.5,2"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.getPercentiles()).containsExactly(1, 1.5, 2); DistributionStatisticConfig.DEFAULT).getPercentiles()).containsExactly(1,
1.5, 2);
} }
@Test @Test
@ -214,48 +216,54 @@ public class PropertiesMeterFilterTests {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.percentiles.spring=1,1.5,2", createProperties("distribution.percentiles.spring=1,1.5,2",
"distribution.percentiles.spring.boot=3,3.5,4")); "distribution.percentiles.spring.boot=3,3.5,4"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.getPercentiles()).containsExactly(3, 3.5, 4); DistributionStatisticConfig.DEFAULT).getPercentiles()).containsExactly(3,
3.5, 4);
} }
@Test @Test
public void configureWhenAllPercentilesSetShouldSetPercentilesToValue() { public void configureWhenAllPercentilesSetShouldSetPercentilesToValue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.percentiles.all=1,1.5,2")); createProperties("distribution.percentiles.all=1,1.5,2"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.getPercentiles()).containsExactly(1, 1.5, 2); DistributionStatisticConfig.DEFAULT).getPercentiles()).containsExactly(1,
1.5, 2);
} }
@Test @Test
public void configureWhenHasSlaShouldSetSlaToValue() { public void configureWhenHasSlaShouldSetSlaToValue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.sla.spring.boot=1,2,3")); createProperties("distribution.sla.spring.boot=1,2,3"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.getSlaBoundaries()).containsExactly(1000000, 2000000, 3000000); DistributionStatisticConfig.DEFAULT).getSlaBoundaries())
.containsExactly(1000000, 2000000, 3000000);
} }
@Test @Test
public void configureWhenHasHigherSlaShouldSetPercentilesToValue() { public void configureWhenHasHigherSlaShouldSetPercentilesToValue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.sla.spring=1,2,3")); createProperties("distribution.sla.spring=1,2,3"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.getSlaBoundaries()).containsExactly(1000000, 2000000, 3000000); DistributionStatisticConfig.DEFAULT).getSlaBoundaries())
.containsExactly(1000000, 2000000, 3000000);
} }
@Test @Test
public void configureWhenHasHigherSlaAndLowerShouldSetSlaToHigher() { public void configureWhenHasHigherSlaAndLowerShouldSetSlaToHigher() {
PropertiesMeterFilter filter = new PropertiesMeterFilter(createProperties( PropertiesMeterFilter filter = new PropertiesMeterFilter(createProperties(
"distribution.sla.spring=1,2,3", "distribution.sla.spring.boot=4,5,6")); "distribution.sla.spring=1,2,3", "distribution.sla.spring.boot=4,5,6"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.getSlaBoundaries()).containsExactly(4000000, 5000000, 6000000); DistributionStatisticConfig.DEFAULT).getSlaBoundaries())
.containsExactly(4000000, 5000000, 6000000);
} }
@Test @Test
public void configureWhenAllSlaSetShouldSetSlaToValue() { public void configureWhenAllSlaSetShouldSetSlaToValue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter( PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.sla.all=1,2,3")); createProperties("distribution.sla.all=1,2,3"));
assertThat(filter.configure(createMeterId("spring.boot"), HistogramConfig.DEFAULT) assertThat(filter.configure(createMeterId("spring.boot"),
.getSlaBoundaries()).containsExactly(1000000, 2000000, 3000000); DistributionStatisticConfig.DEFAULT).getSlaBoundaries())
.containsExactly(1000000, 2000000, 3000000);
} }
@Test @Test
@ -265,12 +273,12 @@ public class PropertiesMeterFilterTests {
Meter.Id timer = createMeterId("spring.boot", Meter.Type.TIMER); Meter.Id timer = createMeterId("spring.boot", Meter.Type.TIMER);
Meter.Id summary = createMeterId("spring.boot", Meter.Type.DISTRIBUTION_SUMMARY); Meter.Id summary = createMeterId("spring.boot", Meter.Type.DISTRIBUTION_SUMMARY);
Meter.Id counter = createMeterId("spring.boot", Meter.Type.COUNTER); Meter.Id counter = createMeterId("spring.boot", Meter.Type.COUNTER);
assertThat(filter.configure(timer, HistogramConfig.DEFAULT).getSlaBoundaries()) assertThat(filter.configure(timer, DistributionStatisticConfig.DEFAULT)
.containsExactly(1000000, 2000000, 3000000); .getSlaBoundaries()).containsExactly(1000000, 2000000, 3000000);
assertThat(filter.configure(summary, HistogramConfig.DEFAULT).getSlaBoundaries()) assertThat(filter.configure(summary, DistributionStatisticConfig.DEFAULT)
.isEmpty(); .getSlaBoundaries()).isEmpty();
assertThat(filter.configure(counter, HistogramConfig.DEFAULT).getSlaBoundaries()) assertThat(filter.configure(counter, DistributionStatisticConfig.DEFAULT)
.isEmpty(); .getSlaBoundaries()).isEmpty();
} }
@Test @Test
@ -280,12 +288,12 @@ public class PropertiesMeterFilterTests {
Meter.Id timer = createMeterId("spring.boot", Meter.Type.TIMER); Meter.Id timer = createMeterId("spring.boot", Meter.Type.TIMER);
Meter.Id summary = createMeterId("spring.boot", Meter.Type.DISTRIBUTION_SUMMARY); Meter.Id summary = createMeterId("spring.boot", Meter.Type.DISTRIBUTION_SUMMARY);
Meter.Id counter = createMeterId("spring.boot", Meter.Type.COUNTER); Meter.Id counter = createMeterId("spring.boot", Meter.Type.COUNTER);
assertThat(filter.configure(timer, HistogramConfig.DEFAULT).getSlaBoundaries()) assertThat(filter.configure(timer, DistributionStatisticConfig.DEFAULT)
.containsExactly(1000000, 2000000, 3000000); .getSlaBoundaries()).containsExactly(1000000, 2000000, 3000000);
assertThat(filter.configure(summary, HistogramConfig.DEFAULT).getSlaBoundaries()) assertThat(filter.configure(summary, DistributionStatisticConfig.DEFAULT)
.containsExactly(1, 2, 3); .getSlaBoundaries()).containsExactly(1, 2, 3);
assertThat(filter.configure(counter, HistogramConfig.DEFAULT).getSlaBoundaries()) assertThat(filter.configure(counter, DistributionStatisticConfig.DEFAULT)
.isEmpty(); .getSlaBoundaries()).isEmpty();
} }
private Id createMeterId(String name) { private Id createMeterId(String name) {

Loading…
Cancel
Save