Skip to content

Provide expiry and bufferLength configuration properties for configuring a distribution statistic #27584

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
5cc443f
Polish
izeye Sep 25, 2019
8dc8ed9
Configure oauth2client in Reactive OAuth2 client auto-config
mbhave Sep 27, 2019
d7815db
Upgrade to Jackson 2.10.0
philwebb Sep 28, 2019
a0e9d90
Polish
philwebb Sep 28, 2019
eb905af
Mention Java 13 in system requirements docs
dreis2211 Sep 27, 2019
d5028a2
Merge pull request #18383 from dreis2211
philwebb Sep 28, 2019
97f0bc9
Polish some external documentation links
dreis2211 Sep 27, 2019
a465ebe
Merge pull request #18384 from dreis2211
philwebb Sep 28, 2019
4a32b7c
Avoid need to escape pipe character in reference tables
dreis2211 Sep 27, 2019
9102bad
Simplify pipe escaping for reference doc tables
dreis2211 Sep 27, 2019
74f988a
Merge pull request #18374 from dreis2211
philwebb Sep 28, 2019
725f784
Add @LocalRSocketServerPort support
veronicavasq Sep 20, 2019
ffef3cc
Polish 'Add @LocalRSocketServerPort support'
philwebb Sep 28, 2019
d9f4a97
Merge pull request #18287 from veronicavasq
philwebb Sep 28, 2019
7f3f8e7
Upgrade deployment test to TomEE 8.0.0
philwebb Sep 28, 2019
ed7b943
Restructure RSocket packages and polish
philwebb Sep 28, 2019
3982af7
Fix package tangle with configuration properties
philwebb Sep 28, 2019
b66c3dd
Fix devtools package tangle
philwebb Sep 28, 2019
12f8c25
Polish
philwebb Sep 28, 2019
d8da22b
Revert "Don't publish spring-boot-docs jar files"
philwebb Sep 28, 2019
636e103
Fix build failure
snicoll Sep 28, 2019
b26310d
Merge branch '2.1.x'
snicoll Sep 28, 2019
24f9138
Avoid duplicate activation-api with Jersey starter
snicoll Sep 28, 2019
19cefe9
Merge branch '2.1.x'
snicoll Sep 28, 2019
86e0bc0
Merge branch '2.1.x'
snicoll Sep 28, 2019
e410931
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Sep 29, 2019
4daf184
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Oct 8, 2019
55bfbf2
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Oct 9, 2019
4a29811
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Oct 12, 2019
bf4328f
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Oct 15, 2019
2e38550
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Oct 15, 2019
9d0b7ed
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Oct 17, 2019
c767b7e
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Oct 23, 2019
9ac32ff
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Nov 15, 2019
3c0be21
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Nov 18, 2019
46c87b8
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Nov 19, 2019
e345e48
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Nov 28, 2019
426f1e3
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Nov 29, 2019
d0bd084
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Dec 3, 2019
6ca2eff
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Dec 4, 2019
2fb1a0e
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Dec 12, 2019
053e02d
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Dec 14, 2019
787cdb6
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Dec 16, 2019
c4c8e2d
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Dec 25, 2019
c6aa1c9
Merge branch 'master' of https://github.com/spring-projects/spring-boot
polarbear567 Feb 28, 2020
5189e6e
Merge remote-tracking branch 'upstream/master'
polarbear567 Jun 19, 2020
b4b3cd2
Merge remote-tracking branch 'upstream/master'
LeoLi-Cisco Jul 17, 2020
ed3f6e0
Merge remote-tracking branch 'upstream/master'
polarbear567 Dec 16, 2020
55e4bd0
Merge branch 'spring-projects:main' into master
polarbear567 Aug 5, 2021
9dc3a09
add expiry and bufferLength in Distribution
polarbear567 Aug 6, 2021
340fc06
add description
polarbear567 Aug 9, 2021
5936b65
add some tests.
polarbear567 Aug 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.boot.actuate.autoconfigure.metrics;

import java.time.Duration;
import java.util.LinkedHashMap;
import java.util.Map;

Expand All @@ -29,6 +30,7 @@
* @author Jon Schneider
* @author Alexander Abramov
* @author Tadaya Tsuyukubo
* @author Leo Li
* @since 2.0.0
*/
@ConfigurationProperties("management.metrics")
Expand Down Expand Up @@ -296,6 +298,21 @@ public static class Distribution {
*/
private final Map<String, String> maximumExpectedValue = new LinkedHashMap<>();

/**
* Specific statistic's expiry for meter IDs starting-with the specified name.
* Values should be a Duration value, the key `all` can also be used to configure
* all meters.
*/
private final Map<String, Duration> expiry = new LinkedHashMap<>();

/**
* Specific statistic's bufferLength for meter IDs starting-with the specified
* name. Samples are accumulated to statistics in ring buffers, and bufferLength
* is the number to keep in the ring buffer, the key `all` can also be used to
* configure all meters.
*/
private final Map<String, Integer> bufferLength = new LinkedHashMap<>();

public Map<String, Boolean> getPercentilesHistogram() {
return this.percentilesHistogram;
}
Expand All @@ -316,6 +333,14 @@ public Map<String, String> getMaximumExpectedValue() {
return this.maximumExpectedValue;
}

public Map<String, Duration> getExpiry() {
return this.expiry;
}

public Map<String, Integer> getBufferLength() {
return this.bufferLength;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* @author Stephane Nicoll
* @author Artsiom Yudovin
* @author Alexander Abramov
* @author Leo Li
* @since 2.0.0
*/
public class PropertiesMeterFilter implements MeterFilter {
Expand Down Expand Up @@ -83,6 +84,8 @@ public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticC
return DistributionStatisticConfig.builder()
.percentilesHistogram(lookupWithFallbackToAll(distribution.getPercentilesHistogram(), id, null))
.percentiles(lookupWithFallbackToAll(distribution.getPercentiles(), id, null))
.expiry(lookupWithFallbackToAll(distribution.getExpiry(), id, null))
.bufferLength(lookupWithFallbackToAll(distribution.getBufferLength(), id, null))
.serviceLevelObjectives(
convertServiceLevelObjectives(id.getType(), lookup(distribution.getSlo(), id, null)))
.minimumExpectedValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* @author Phillip Webb
* @author Jon Schneider
* @author Artsiom Yudovin
* @author Leo Li
*/
class PropertiesMeterFilterTests {

Expand Down Expand Up @@ -275,6 +276,71 @@ void configureWhenHasHigherMaximumExpectedValueAndLowerShouldSetMaximumExpectedV
.getMaximumExpectedValueAsDouble()).isEqualTo(Duration.ofMillis(10000).toNanos());
}

@Test
void configureWhenHasExpiryShouldSetExpiryToValue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.expiry[spring.boot]=5ms"));
assertThat(filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getExpiry())
.isEqualTo(Duration.ofMillis(5));
}

@Test
void configureWhenHasHigherExpiryShouldSetExpiryToValue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter(createProperties("distribution.expiry.spring=5ms"));
assertThat(filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getExpiry())
.isEqualTo(Duration.ofMillis(5));
}

@Test
void configureWhenHasHigherExpiryAndLowerShouldSetExpiryToHigher() {
PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.expiry.spring=5ms", "distribution.expiry[spring.boot]=10ms"));
assertThat(filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getExpiry())
.isEqualTo(Duration.ofMillis(10));
}

@Test
void configureWhenAllExpirySetShouldSetExpiryToValue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter(createProperties("distribution.expiry.all=5ms"));
assertThat(filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getExpiry())
.isEqualTo(Duration.ofMillis(5));
}

@Test
void configureWhenHasBufferLengthShouldSetBufferLengthToValue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.bufferLength[spring.boot]=3"));
assertThat(
filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength())
.isEqualTo(3);
}

@Test
void configureWhenHasHigherBufferLengthShouldSetBufferLengthToValue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.bufferLength.spring=3"));
assertThat(
filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength())
.isEqualTo(3);
}

@Test
void configureWhenHasHigherBufferLengthAndLowerShouldSetBufferLengthToHigher() {
PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("distribution.bufferLength.spring=2", "distribution.bufferLength[spring.boot]=3"));
assertThat(
filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength())
.isEqualTo(3);
}

@Test
void configureWhenAllBufferLengthSetShouldSetBufferLengthToValue() {
PropertiesMeterFilter filter = new PropertiesMeterFilter(createProperties("distribution.bufferLength.all=3"));
assertThat(
filter.configure(createMeterId("spring.boot"), DistributionStatisticConfig.DEFAULT).getBufferLength())
.isEqualTo(3);
}

private Id createMeterId(String name) {
Meter.Type meterType = Type.TIMER;
return createMeterId(name, meterType);
Expand Down