Skip to content

Commit ccbe758

Browse files
committed
Expose step property for StatsdConfig
1 parent 4cc1b5e commit ccbe758

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ public class StatsdProperties {
7171
*/
7272
private Duration pollingFrequency = Duration.ofSeconds(10);
7373

74+
/**
75+
* The step size to use in computing windowed statistics like max. The default is 1
76+
* minute. To get the most out of these statistics, align the step interval to be
77+
* close to your scrape interval.
78+
*/
79+
private Duration step = Duration.ofMinutes(1);
80+
7481
/**
7582
* Whether to send unchanged meters to the StatsD server.
7683
*/
@@ -137,6 +144,14 @@ public void setPollingFrequency(Duration pollingFrequency) {
137144
this.pollingFrequency = pollingFrequency;
138145
}
139146

147+
public Duration getStep() {
148+
return this.step;
149+
}
150+
151+
public void setStep(Duration step) {
152+
this.step = step;
153+
}
154+
140155
public boolean isPublishUnchangedMeters() {
141156
return this.publishUnchangedMeters;
142157
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ public Duration pollingFrequency() {
8181
return get(StatsdProperties::getPollingFrequency, StatsdConfig.super::pollingFrequency);
8282
}
8383

84+
@Override
85+
public Duration step() {
86+
return get(StatsdProperties::getStep, StatsdConfig.super::step);
87+
}
88+
8489
@Override
8590
public boolean publishUnchangedMeters() {
8691
return get(StatsdProperties::isPublishUnchangedMeters, StatsdConfig.super::publishUnchangedMeters);

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapterTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ void whenPropertiesPollingFrequencyIsSetAdapterPollingFrequencyReturnsIt() {
8282
.isEqualTo(properties.getPollingFrequency());
8383
}
8484

85+
@Test
86+
void whenPropertiesStepIsSetAdapterStepReturnsIt() {
87+
StatsdProperties properties = new StatsdProperties();
88+
properties.setStep(Duration.ofSeconds(1));
89+
assertThat(new StatsdPropertiesConfigAdapter(properties).step()).isEqualTo(properties.getStep());
90+
}
91+
8592
@Test
8693
void whenPropertiesPublishUnchangedMetersIsSetAdapterPublishUnchangedMetersReturnsIt() {
8794
StatsdProperties properties = new StatsdProperties();

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ void defaultValuesAreConsistent() {
3939
assertThat(properties.getProtocol()).isEqualTo(config.protocol());
4040
assertThat(properties.getMaxPacketLength()).isEqualTo(config.maxPacketLength());
4141
assertThat(properties.getPollingFrequency()).isEqualTo(config.pollingFrequency());
42+
assertThat(properties.getStep()).isEqualTo(config.step());
4243
assertThat(properties.isPublishUnchangedMeters()).isEqualTo(config.publishUnchangedMeters());
4344
assertThat(properties.isBuffered()).isEqualTo(config.buffered());
4445
}

0 commit comments

Comments
 (0)