Skip to content

Commit 935d621

Browse files
committed
Fix mapping of Wavefront base properties
Closes gh-14839
1 parent 94b2092 commit 935d621

File tree

3 files changed

+79
-3
lines changed

3 files changed

+79
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import io.micrometer.wavefront.WavefrontConfig;
2020

21-
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PropertiesConfigAdapter;
21+
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapter;
2222

2323
/**
2424
* Adapter to convert {@link WavefrontProperties} to a {@link WavefrontConfig}.
@@ -27,7 +27,8 @@
2727
* @since 2.0.0
2828
*/
2929
public class WavefrontPropertiesConfigAdapter
30-
extends PropertiesConfigAdapter<WavefrontProperties> implements WavefrontConfig {
30+
extends StepRegistryPropertiesConfigAdapter<WavefrontProperties>
31+
implements WavefrontConfig {
3132

3233
public WavefrontPropertiesConfigAdapter(WavefrontProperties properties) {
3334
super(properties);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright 2012-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.autoconfigure.metrics.export.wavefront;
18+
19+
import java.net.URI;
20+
21+
import org.junit.Test;
22+
23+
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
24+
25+
import static org.assertj.core.api.Assertions.assertThat;
26+
27+
/**
28+
* Tests for {@link WavefrontPropertiesConfigAdapter}.
29+
*
30+
* @author Stephane Nicoll
31+
*/
32+
public class WavefrontPropertiesConfigAdapterTests extends
33+
StepRegistryPropertiesConfigAdapterTests<WavefrontProperties, WavefrontPropertiesConfigAdapter> {
34+
35+
@Override
36+
protected WavefrontProperties createProperties() {
37+
return new WavefrontProperties();
38+
}
39+
40+
@Override
41+
protected WavefrontPropertiesConfigAdapter createConfigAdapter(
42+
WavefrontProperties properties) {
43+
return new WavefrontPropertiesConfigAdapter(properties);
44+
}
45+
46+
@Test
47+
public void whenPropertiesUriIsSetAdapterUriReturnsIt() {
48+
WavefrontProperties properties = createProperties();
49+
properties.setUri(URI.create("https://wavefront.example.com"));
50+
assertThat(createConfigAdapter(properties).uri())
51+
.isEqualTo("https://wavefront.example.com");
52+
}
53+
54+
@Test
55+
public void whenPropertiesSourceIsSetAdapterSourceReturnsIt() {
56+
WavefrontProperties properties = createProperties();
57+
properties.setSource("test");
58+
assertThat(createConfigAdapter(properties).source()).isEqualTo("test");
59+
}
60+
61+
@Test
62+
public void whenPropertiesApiTokenIsSetAdapterApiTokenReturnsIt() {
63+
WavefrontProperties properties = createProperties();
64+
properties.setApiToken("ABC123");
65+
assertThat(createConfigAdapter(properties).apiToken()).isEqualTo("ABC123");
66+
}
67+
68+
@Test
69+
public void whenPropertiesGlobalPrefixIsSetAdapterGlobalPrefixReturnsIt() {
70+
WavefrontProperties properties = createProperties();
71+
properties.setGlobalPrefix("test");
72+
assertThat(createConfigAdapter(properties).globalPrefix()).isEqualTo("test");
73+
}
74+
75+
}

spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ content into your application. Rather, pick only the properties that you need.
14241424
management.metrics.export.wavefront.num-threads=2 # Number of threads to use with the metrics publishing scheduler.
14251425
management.metrics.export.wavefront.read-timeout=10s # Read timeout for requests to this backend.
14261426
management.metrics.export.wavefront.source= # Unique identifier for the app instance that is the source of metrics being published to Wavefront. Defaults to the local host name.
1427-
management.metrics.export.wavefront.step=10s # Step size (i.e. reporting frequency) to use.
1427+
management.metrics.export.wavefront.step=1m # Step size (i.e. reporting frequency) to use.
14281428
management.metrics.export.wavefront.uri=https://longboard.wavefront.com # URI to ship metrics to.
14291429
management.metrics.use-global-registry=true # Whether auto-configured MeterRegistry implementations should be bound to the global static registry on Metrics.
14301430
management.metrics.web.client.max-uri-tags=100 # Maximum number of unique URI tag values allowed. After the max number of tag values is reached, metrics with additional tag values are denied by filter.

0 commit comments

Comments
 (0)