Commit 47f93793 authored by Stephane Nicoll's avatar Stephane Nicoll

Adapt to changes in latest Micrometer snapshot

See gh-14522
parent 0dc2375e
...@@ -45,8 +45,8 @@ public class DynatraceProperties extends StepRegistryProperties { ...@@ -45,8 +45,8 @@ public class DynatraceProperties extends StepRegistryProperties {
private String technologyType = "java"; private String technologyType = "java";
/** /**
* URI to ship metrics to. If you need to publish metrics to an internal proxy * URI to ship metrics to. Should be used for SaaS, self managed instances or to
* en-route to Dynatrace, you can define the location of the proxy with this. * en-route through an internal proxy.
*/ */
private String uri; private String uri;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.springframework.boot.actuate.autoconfigure.metrics.export.dynatrace; package org.springframework.boot.actuate.autoconfigure.metrics.export.dynatrace;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
import io.micrometer.core.instrument.Clock; import io.micrometer.core.instrument.Clock;
import io.micrometer.dynatrace.DynatraceConfig; import io.micrometer.dynatrace.DynatraceConfig;
...@@ -39,6 +40,7 @@ import static org.mockito.Mockito.verify; ...@@ -39,6 +40,7 @@ import static org.mockito.Mockito.verify;
* Tests for {@link DynatraceMetricsExportAutoConfiguration}. * Tests for {@link DynatraceMetricsExportAutoConfiguration}.
* *
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Stephane Nicoll
*/ */
public class DynatraceMetricsExportAutoConfigurationTests { public class DynatraceMetricsExportAutoConfigurationTests {
...@@ -61,8 +63,7 @@ public class DynatraceMetricsExportAutoConfigurationTests { ...@@ -61,8 +63,7 @@ public class DynatraceMetricsExportAutoConfigurationTests {
@Test @Test
public void autoConfiguresConfigAndMeterRegistry() { public void autoConfiguresConfigAndMeterRegistry() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class) this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues( .with(mandatoryProperties())
"management.metrics.export.dynatrace.uri=https://dynatrace.example.com")
.run((context) -> assertThat(context) .run((context) -> assertThat(context)
.hasSingleBean(DynatraceMeterRegistry.class) .hasSingleBean(DynatraceMeterRegistry.class)
.hasSingleBean(DynatraceConfig.class)); .hasSingleBean(DynatraceConfig.class));
...@@ -88,8 +89,7 @@ public class DynatraceMetricsExportAutoConfigurationTests { ...@@ -88,8 +89,7 @@ public class DynatraceMetricsExportAutoConfigurationTests {
@Test @Test
public void allowsCustomRegistryToBeUsed() { public void allowsCustomRegistryToBeUsed() {
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class) this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
.withPropertyValues( .with(mandatoryProperties())
"management.metrics.export.dynatrace.uri=https://dynatrace.example.com")
.run((context) -> assertThat(context) .run((context) -> assertThat(context)
.hasSingleBean(DynatraceMeterRegistry.class) .hasSingleBean(DynatraceMeterRegistry.class)
.hasBean("customRegistry").hasSingleBean(DynatraceConfig.class)); .hasBean("customRegistry").hasSingleBean(DynatraceConfig.class));
...@@ -98,10 +98,7 @@ public class DynatraceMetricsExportAutoConfigurationTests { ...@@ -98,10 +98,7 @@ public class DynatraceMetricsExportAutoConfigurationTests {
@Test @Test
public void stopsMeterRegistryWhenContextIsClosed() { public void stopsMeterRegistryWhenContextIsClosed() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class) this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.dynatrace.api-token=abcde", .with(mandatoryProperties()).run((context) -> {
"management.metrics.export.dynatrace.uri=https://dynatrace.example.com",
"management.metrics.export.dynatrace.deviceId=test")
.run((context) -> {
DynatraceMeterRegistry registry = spyOnDisposableBean( DynatraceMeterRegistry registry = spyOnDisposableBean(
DynatraceMeterRegistry.class, context); DynatraceMeterRegistry.class, context);
context.close(); context.close();
...@@ -109,6 +106,13 @@ public class DynatraceMetricsExportAutoConfigurationTests { ...@@ -109,6 +106,13 @@ public class DynatraceMetricsExportAutoConfigurationTests {
}); });
} }
private Function<ApplicationContextRunner, ApplicationContextRunner> mandatoryProperties() {
return (runner) -> runner.withPropertyValues(
"management.metrics.export.dynatrace.uri=https://dynatrace.example.com",
"management.metrics.export.dynatrace.api-token=abcde",
"management.metrics.export.dynatrace.device-id=test");
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private <T> T spyOnDisposableBean(Class<T> type, private <T> T spyOnDisposableBean(Class<T> type,
AssertableApplicationContext context) { AssertableApplicationContext context) {
...@@ -139,16 +143,17 @@ public class DynatraceMetricsExportAutoConfigurationTests { ...@@ -139,16 +143,17 @@ public class DynatraceMetricsExportAutoConfigurationTests {
@Bean @Bean
public DynatraceConfig customConfig() { public DynatraceConfig customConfig() {
return new DynatraceConfig() { return (k) -> {
if ("dynatrace.uri".equals(k)) {
@Override return "https://dynatrace.example.com";
public String get(String k) {
if ("dynatrace.uri".equals(k)) {
return "https://dynatrace.example.com";
}
return null;
} }
if ("dynatrace.apiToken".equals(k)) {
return "abcde";
}
if ("dynatrace.deviceId".equals(k)) {
return "test";
}
return null;
}; };
} }
......
...@@ -1412,7 +1412,7 @@ content into your application. Rather, pick only the properties that you need. ...@@ -1412,7 +1412,7 @@ content into your application. Rather, pick only the properties that you need.
management.metrics.export.dynatrace.read-timeout=10s # Read timeout for requests to this backend. management.metrics.export.dynatrace.read-timeout=10s # Read timeout for requests to this backend.
management.metrics.export.dynatrace.step=1m # Step size (i.e. reporting frequency) to use. management.metrics.export.dynatrace.step=1m # Step size (i.e. reporting frequency) to use.
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. 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.
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. 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.
management.metrics.export.ganglia.addressing-mode=multicast # UDP addressing mode, either unicast or multicast. management.metrics.export.ganglia.addressing-mode=multicast # UDP addressing mode, either unicast or multicast.
management.metrics.export.ganglia.duration-units=milliseconds # Base time unit used to report durations. management.metrics.export.ganglia.duration-units=milliseconds # Base time unit used to report durations.
management.metrics.export.ganglia.enabled=true # Whether exporting of metrics to Ganglia is enabled. management.metrics.export.ganglia.enabled=true # Whether exporting of metrics to Ganglia is enabled.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment