Skip to content

Commit aae8665

Browse files
committed
Add missing management.metrics.export.wavefront properties
Closes gh-36498
1 parent a6c19da commit aae8665

File tree

4 files changed

+84
-6
lines changed

4 files changed

+84
-6
lines changed

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

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,6 +57,21 @@ public class WavefrontProperties extends PushRegistryProperties {
5757
*/
5858
private String globalPrefix;
5959

60+
/**
61+
* Whether to report histogram distributions aggregated into minute intervals.
62+
*/
63+
private boolean reportMinuteDistribution = true;
64+
65+
/**
66+
* Whether to report histogram distributions aggregated into hour intervals.
67+
*/
68+
private boolean reportHourDistribution;
69+
70+
/**
71+
* Whether to report histogram distributions aggregated into day intervals.
72+
*/
73+
private boolean reportDayDistribution;
74+
6075
private final Sender sender = new Sender();
6176

6277
public URI getUri() {
@@ -95,6 +110,30 @@ public Sender getSender() {
95110
return this.sender;
96111
}
97112

113+
public boolean isReportMinuteDistribution() {
114+
return this.reportMinuteDistribution;
115+
}
116+
117+
public void setReportMinuteDistribution(boolean reportMinuteDistribution) {
118+
this.reportMinuteDistribution = reportMinuteDistribution;
119+
}
120+
121+
public boolean isReportHourDistribution() {
122+
return this.reportHourDistribution;
123+
}
124+
125+
public void setReportHourDistribution(boolean reportHourDistribution) {
126+
this.reportHourDistribution = reportHourDistribution;
127+
}
128+
129+
public boolean isReportDayDistribution() {
130+
return this.reportDayDistribution;
131+
}
132+
133+
public void setReportDayDistribution(boolean reportDayDistribution) {
134+
this.reportDayDistribution = reportDayDistribution;
135+
}
136+
98137
public static class Sender {
99138

100139
/**

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,6 +48,10 @@ public String uri() {
4848
return get(this::getUriAsString, WavefrontConfig.DEFAULT_DIRECT::uri);
4949
}
5050

51+
private String getUriAsString(WavefrontProperties properties) {
52+
return (properties.getUri() != null) ? properties.getUri().toString() : null;
53+
}
54+
5155
@Override
5256
public String source() {
5357
return get(WavefrontProperties::getSource, WavefrontConfig.super::source);
@@ -63,8 +67,19 @@ public String globalPrefix() {
6367
return get(WavefrontProperties::getGlobalPrefix, WavefrontConfig.super::globalPrefix);
6468
}
6569

66-
private String getUriAsString(WavefrontProperties properties) {
67-
return (properties.getUri() != null) ? properties.getUri().toString() : null;
70+
@Override
71+
public boolean reportMinuteDistribution() {
72+
return get(WavefrontProperties::isReportMinuteDistribution, WavefrontConfig.super::reportMinuteDistribution);
73+
}
74+
75+
@Override
76+
public boolean reportHourDistribution() {
77+
return get(WavefrontProperties::isReportHourDistribution, WavefrontConfig.super::reportHourDistribution);
78+
}
79+
80+
@Override
81+
public boolean reportDayDistribution() {
82+
return get(WavefrontProperties::isReportDayDistribution, WavefrontConfig.super::reportDayDistribution);
6883
}
6984

7085
}

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -70,4 +70,25 @@ void whenPropertiesGlobalPrefixIsSetAdapterGlobalPrefixReturnsIt() {
7070
assertThat(createConfigAdapter(properties).globalPrefix()).isEqualTo("test");
7171
}
7272

73+
@Test
74+
void whenPropertiesReportMinuteDistributionIsSetAdapterReportMinuteDistributionReturnsIt() {
75+
WavefrontProperties properties = createProperties();
76+
properties.setReportMinuteDistribution(false);
77+
assertThat(createConfigAdapter(properties).reportMinuteDistribution()).isFalse();
78+
}
79+
80+
@Test
81+
void whenPropertiesReportHourDistributionIsSetAdapterReportHourDistributionReturnsIt() {
82+
WavefrontProperties properties = createProperties();
83+
properties.setReportHourDistribution(true);
84+
assertThat(createConfigAdapter(properties).reportHourDistribution()).isTrue();
85+
}
86+
87+
@Test
88+
void whenPropertiesReportDayDistributionIsSetAdapterReportDayDistributionReturnsIt() {
89+
WavefrontProperties properties = createProperties();
90+
properties.setReportDayDistribution(true);
91+
assertThat(createConfigAdapter(properties).reportDayDistribution()).isTrue();
92+
}
93+
7394
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,6 +37,9 @@ void defaultValuesAreConsistent() {
3737
assertStepRegistryDefaultValues(properties, config);
3838
assertThat(properties.getUri().toString()).isEqualTo(config.uri());
3939
assertThat(properties.getGlobalPrefix()).isEqualTo(config.globalPrefix());
40+
assertThat(properties.isReportMinuteDistribution()).isEqualTo(config.reportMinuteDistribution());
41+
assertThat(properties.isReportHourDistribution()).isEqualTo(config.reportHourDistribution());
42+
assertThat(properties.isReportDayDistribution()).isEqualTo(config.reportDayDistribution());
4043
}
4144

4245
}

0 commit comments

Comments
 (0)