Polish "Add expiry and bufferLength configuration properties"
See gh-27584
This commit is contained in:
parent
888acb94fc
commit
1475309b4d
|
|
@ -30,7 +30,6 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||||
* @author Jon Schneider
|
* @author Jon Schneider
|
||||||
* @author Alexander Abramov
|
* @author Alexander Abramov
|
||||||
* @author Tadaya Tsuyukubo
|
* @author Tadaya Tsuyukubo
|
||||||
* @author Leo Li
|
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties("management.metrics")
|
@ConfigurationProperties("management.metrics")
|
||||||
|
|
@ -299,16 +298,16 @@ public class MetricsProperties {
|
||||||
private final Map<String, String> maximumExpectedValue = new LinkedHashMap<>();
|
private final Map<String, String> maximumExpectedValue = new LinkedHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specific statistic's expiry for meter IDs starting-with the specified name.
|
* Maximum amount of time that samples for meter IDs starting with the specified
|
||||||
* Values should be a Duration value, the key `all` can also be used to configure
|
* name are accumulated to decaying distribution statistics before they are reset
|
||||||
* all meters.
|
* and rotated. The longest match wins, the key `all` can also be used to
|
||||||
|
* configure all meters.
|
||||||
*/
|
*/
|
||||||
private final Map<String, Duration> expiry = new LinkedHashMap<>();
|
private final Map<String, Duration> expiry = new LinkedHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specific statistic's bufferLength for meter IDs starting-with the specified
|
* Number of histograms for meter IDs starting with the specified name to keep in
|
||||||
* name. Samples are accumulated to statistics in ring buffers, and bufferLength
|
* the ring buffer. The longest match wins, the key `all` can also be used to
|
||||||
* is the number to keep in the ring buffer, the key `all` can also be used to
|
|
||||||
* configure all meters.
|
* configure all meters.
|
||||||
*/
|
*/
|
||||||
private final Map<String, Integer> bufferLength = new LinkedHashMap<>();
|
private final Map<String, Integer> bufferLength = new LinkedHashMap<>();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -42,7 +42,6 @@ import org.springframework.util.StringUtils;
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @author Artsiom Yudovin
|
* @author Artsiom Yudovin
|
||||||
* @author Alexander Abramov
|
* @author Alexander Abramov
|
||||||
* @author Leo Li
|
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public class PropertiesMeterFilter implements MeterFilter {
|
public class PropertiesMeterFilter implements MeterFilter {
|
||||||
|
|
@ -84,15 +83,14 @@ public class PropertiesMeterFilter implements MeterFilter {
|
||||||
return DistributionStatisticConfig.builder()
|
return DistributionStatisticConfig.builder()
|
||||||
.percentilesHistogram(lookupWithFallbackToAll(distribution.getPercentilesHistogram(), id, null))
|
.percentilesHistogram(lookupWithFallbackToAll(distribution.getPercentilesHistogram(), id, null))
|
||||||
.percentiles(lookupWithFallbackToAll(distribution.getPercentiles(), id, null))
|
.percentiles(lookupWithFallbackToAll(distribution.getPercentiles(), id, null))
|
||||||
.expiry(lookupWithFallbackToAll(distribution.getExpiry(), id, null))
|
|
||||||
.bufferLength(lookupWithFallbackToAll(distribution.getBufferLength(), id, null))
|
|
||||||
.serviceLevelObjectives(
|
.serviceLevelObjectives(
|
||||||
convertServiceLevelObjectives(id.getType(), lookup(distribution.getSlo(), id, null)))
|
convertServiceLevelObjectives(id.getType(), lookup(distribution.getSlo(), id, null)))
|
||||||
.minimumExpectedValue(
|
.minimumExpectedValue(
|
||||||
convertMeterValue(id.getType(), lookup(distribution.getMinimumExpectedValue(), id, null)))
|
convertMeterValue(id.getType(), lookup(distribution.getMinimumExpectedValue(), id, null)))
|
||||||
.maximumExpectedValue(
|
.maximumExpectedValue(
|
||||||
convertMeterValue(id.getType(), lookup(distribution.getMaximumExpectedValue(), id, null)))
|
convertMeterValue(id.getType(), lookup(distribution.getMaximumExpectedValue(), id, null)))
|
||||||
.build().merge(config);
|
.expiry(lookupWithFallbackToAll(distribution.getExpiry(), id, null))
|
||||||
|
.bufferLength(lookupWithFallbackToAll(distribution.getBufferLength(), id, null)).build().merge(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double[] convertServiceLevelObjectives(Meter.Type meterType, ServiceLevelObjectiveBoundary[] slo) {
|
private double[] convertServiceLevelObjectives(Meter.Type meterType, ServiceLevelObjectiveBoundary[] slo) {
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,7 @@ class PropertiesMeterFilterTests {
|
||||||
@Test
|
@Test
|
||||||
void configureWhenHasBufferLengthShouldSetBufferLengthToValue() {
|
void configureWhenHasBufferLengthShouldSetBufferLengthToValue() {
|
||||||
PropertiesMeterFilter filter = new PropertiesMeterFilter(
|
PropertiesMeterFilter filter = new PropertiesMeterFilter(
|
||||||
createProperties("distribution.bufferLength[spring.boot]=3"));
|
createProperties("distribution.buffer-length.spring.boot=3"));
|
||||||
assertThat(
|
assertThat(
|
||||||
filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength())
|
filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength())
|
||||||
.isEqualTo(3);
|
.isEqualTo(3);
|
||||||
|
|
@ -318,7 +318,7 @@ class PropertiesMeterFilterTests {
|
||||||
@Test
|
@Test
|
||||||
void configureWhenHasHigherBufferLengthShouldSetBufferLengthToValue() {
|
void configureWhenHasHigherBufferLengthShouldSetBufferLengthToValue() {
|
||||||
PropertiesMeterFilter filter = new PropertiesMeterFilter(
|
PropertiesMeterFilter filter = new PropertiesMeterFilter(
|
||||||
createProperties("distribution.bufferLength.spring=3"));
|
createProperties("distribution.buffer-length.spring=3"));
|
||||||
assertThat(
|
assertThat(
|
||||||
filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength())
|
filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength())
|
||||||
.isEqualTo(3);
|
.isEqualTo(3);
|
||||||
|
|
@ -327,7 +327,7 @@ class PropertiesMeterFilterTests {
|
||||||
@Test
|
@Test
|
||||||
void configureWhenHasHigherBufferLengthAndLowerShouldSetBufferLengthToHigher() {
|
void configureWhenHasHigherBufferLengthAndLowerShouldSetBufferLengthToHigher() {
|
||||||
PropertiesMeterFilter filter = new PropertiesMeterFilter(
|
PropertiesMeterFilter filter = new PropertiesMeterFilter(
|
||||||
createProperties("distribution.bufferLength.spring=2", "distribution.bufferLength[spring.boot]=3"));
|
createProperties("distribution.buffer-length.spring=2", "distribution.buffer-length.spring.boot=3"));
|
||||||
assertThat(
|
assertThat(
|
||||||
filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength())
|
filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength())
|
||||||
.isEqualTo(3);
|
.isEqualTo(3);
|
||||||
|
|
@ -335,7 +335,7 @@ class PropertiesMeterFilterTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void configureWhenAllBufferLengthSetShouldSetBufferLengthToValue() {
|
void configureWhenAllBufferLengthSetShouldSetBufferLengthToValue() {
|
||||||
PropertiesMeterFilter filter = new PropertiesMeterFilter(createProperties("distribution.bufferLength.all=3"));
|
PropertiesMeterFilter filter = new PropertiesMeterFilter(createProperties("distribution.buffer-length.all=3"));
|
||||||
assertThat(
|
assertThat(
|
||||||
filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength())
|
filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength())
|
||||||
.isEqualTo(3);
|
.isEqualTo(3);
|
||||||
|
|
|
||||||
|
|
@ -1153,6 +1153,10 @@ The following properties allow per-meter customization:
|
||||||
| configprop:management.metrics.distribution.percentiles[]
|
| configprop:management.metrics.distribution.percentiles[]
|
||||||
| Publish percentile values computed in your application
|
| Publish percentile values computed in your application
|
||||||
|
|
||||||
|
| configprop:management.metrics.distribution.expiry[], configprop:management.metrics.distribution.buffer-length[]
|
||||||
|
| Give greater weight to recent samples by accumulating them in ring buffers which rotate after a configurable expiry, with a
|
||||||
|
configurable buffer length.
|
||||||
|
|
||||||
| configprop:management.metrics.distribution.slo[]
|
| configprop:management.metrics.distribution.slo[]
|
||||||
| Publish a cumulative histogram with buckets defined by your service-level objectives.
|
| Publish a cumulative histogram with buckets defined by your service-level objectives.
|
||||||
|===
|
|===
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue