Skip to content

Commit 47f9379

Browse files
committed
Adapt to changes in latest Micrometer snapshot
See gh-14522
1 parent 0dc2375 commit 47f9379

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public class DynatraceProperties extends StepRegistryProperties {
4545
private String technologyType = "java";
4646

4747
/**
48-
* URI to ship metrics to. If you need to publish metrics to an internal proxy
49-
* en-route to Dynatrace, you can define the location of the proxy with this.
48+
* URI to ship metrics to. Should be used for SaaS, self managed instances or to
49+
* en-route through an internal proxy.
5050
*/
5151
private String uri;
5252

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

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.boot.actuate.autoconfigure.metrics.export.dynatrace;
1818

1919
import java.util.Map;
20+
import java.util.function.Function;
2021

2122
import io.micrometer.core.instrument.Clock;
2223
import io.micrometer.dynatrace.DynatraceConfig;
@@ -39,6 +40,7 @@
3940
* Tests for {@link DynatraceMetricsExportAutoConfiguration}.
4041
*
4142
* @author Andy Wilkinson
43+
* @author Stephane Nicoll
4244
*/
4345
public class DynatraceMetricsExportAutoConfigurationTests {
4446

@@ -61,8 +63,7 @@ public void failsWithoutAUri() {
6163
@Test
6264
public void autoConfiguresConfigAndMeterRegistry() {
6365
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
64-
.withPropertyValues(
65-
"management.metrics.export.dynatrace.uri=https://dynatrace.example.com")
66+
.with(mandatoryProperties())
6667
.run((context) -> assertThat(context)
6768
.hasSingleBean(DynatraceMeterRegistry.class)
6869
.hasSingleBean(DynatraceConfig.class));
@@ -88,8 +89,7 @@ public void allowsCustomConfigToBeUsed() {
8889
@Test
8990
public void allowsCustomRegistryToBeUsed() {
9091
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
91-
.withPropertyValues(
92-
"management.metrics.export.dynatrace.uri=https://dynatrace.example.com")
92+
.with(mandatoryProperties())
9393
.run((context) -> assertThat(context)
9494
.hasSingleBean(DynatraceMeterRegistry.class)
9595
.hasBean("customRegistry").hasSingleBean(DynatraceConfig.class));
@@ -98,17 +98,21 @@ public void allowsCustomRegistryToBeUsed() {
9898
@Test
9999
public void stopsMeterRegistryWhenContextIsClosed() {
100100
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
101-
.withPropertyValues("management.metrics.export.dynatrace.api-token=abcde",
102-
"management.metrics.export.dynatrace.uri=https://dynatrace.example.com",
103-
"management.metrics.export.dynatrace.deviceId=test")
104-
.run((context) -> {
101+
.with(mandatoryProperties()).run((context) -> {
105102
DynatraceMeterRegistry registry = spyOnDisposableBean(
106103
DynatraceMeterRegistry.class, context);
107104
context.close();
108105
verify(registry).stop();
109106
});
110107
}
111108

109+
private Function<ApplicationContextRunner, ApplicationContextRunner> mandatoryProperties() {
110+
return (runner) -> runner.withPropertyValues(
111+
"management.metrics.export.dynatrace.uri=https://dynatrace.example.com",
112+
"management.metrics.export.dynatrace.api-token=abcde",
113+
"management.metrics.export.dynatrace.device-id=test");
114+
}
115+
112116
@SuppressWarnings("unchecked")
113117
private <T> T spyOnDisposableBean(Class<T> type,
114118
AssertableApplicationContext context) {
@@ -139,16 +143,17 @@ static class CustomConfigConfiguration {
139143

140144
@Bean
141145
public DynatraceConfig customConfig() {
142-
return new DynatraceConfig() {
143-
144-
@Override
145-
public String get(String k) {
146-
if ("dynatrace.uri".equals(k)) {
147-
return "https://dynatrace.example.com";
148-
}
149-
return null;
146+
return (k) -> {
147+
if ("dynatrace.uri".equals(k)) {
148+
return "https://dynatrace.example.com";
150149
}
151-
150+
if ("dynatrace.apiToken".equals(k)) {
151+
return "abcde";
152+
}
153+
if ("dynatrace.deviceId".equals(k)) {
154+
return "test";
155+
}
156+
return null;
152157
};
153158
}
154159

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
@@ -1412,7 +1412,7 @@ content into your application. Rather, pick only the properties that you need.
14121412
management.metrics.export.dynatrace.read-timeout=10s # Read timeout for requests to this backend.
14131413
management.metrics.export.dynatrace.step=1m # Step size (i.e. reporting frequency) to use.
14141414
management.metrics.export.dynatrace.technology-type=java # Technology type for exported metrics. Used to group metrics under a logical technology name in the Dynatrace UI.
1415-
management.metrics.export.dynatrace.uri= # URI to ship metrics to. If you need to publish metrics to an internal proxy en-route to Dynatrace, you can define the location of the proxy with this.
1415+
management.metrics.export.dynatrace.uri= # URI to ship metrics to. Should be used for SaaS, self managed instances or to en-route through an internal proxy.
14161416
management.metrics.export.ganglia.addressing-mode=multicast # UDP addressing mode, either unicast or multicast.
14171417
management.metrics.export.ganglia.duration-units=milliseconds # Base time unit used to report durations.
14181418
management.metrics.export.ganglia.enabled=true # Whether exporting of metrics to Ganglia is enabled.

0 commit comments

Comments
 (0)