Adapt to changes in latest Micrometer snapshot
See gh-14522
This commit is contained in:
@@ -45,8 +45,8 @@ public class DynatraceProperties extends StepRegistryProperties {
|
||||
private String technologyType = "java";
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* URI to ship metrics to. Should be used for SaaS, self managed instances or to
|
||||
* en-route through an internal proxy.
|
||||
*/
|
||||
private String uri;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.dynatrace;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import io.micrometer.core.instrument.Clock;
|
||||
import io.micrometer.dynatrace.DynatraceConfig;
|
||||
@@ -39,6 +40,7 @@ import static org.mockito.Mockito.verify;
|
||||
* Tests for {@link DynatraceMetricsExportAutoConfiguration}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class DynatraceMetricsExportAutoConfigurationTests {
|
||||
|
||||
@@ -61,8 +63,7 @@ public class DynatraceMetricsExportAutoConfigurationTests {
|
||||
@Test
|
||||
public void autoConfiguresConfigAndMeterRegistry() {
|
||||
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
|
||||
.withPropertyValues(
|
||||
"management.metrics.export.dynatrace.uri=https://dynatrace.example.com")
|
||||
.with(mandatoryProperties())
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(DynatraceMeterRegistry.class)
|
||||
.hasSingleBean(DynatraceConfig.class));
|
||||
@@ -88,8 +89,7 @@ public class DynatraceMetricsExportAutoConfigurationTests {
|
||||
@Test
|
||||
public void allowsCustomRegistryToBeUsed() {
|
||||
this.contextRunner.withUserConfiguration(CustomRegistryConfiguration.class)
|
||||
.withPropertyValues(
|
||||
"management.metrics.export.dynatrace.uri=https://dynatrace.example.com")
|
||||
.with(mandatoryProperties())
|
||||
.run((context) -> assertThat(context)
|
||||
.hasSingleBean(DynatraceMeterRegistry.class)
|
||||
.hasBean("customRegistry").hasSingleBean(DynatraceConfig.class));
|
||||
@@ -98,10 +98,7 @@ public class DynatraceMetricsExportAutoConfigurationTests {
|
||||
@Test
|
||||
public void stopsMeterRegistryWhenContextIsClosed() {
|
||||
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
|
||||
.withPropertyValues("management.metrics.export.dynatrace.api-token=abcde",
|
||||
"management.metrics.export.dynatrace.uri=https://dynatrace.example.com",
|
||||
"management.metrics.export.dynatrace.deviceId=test")
|
||||
.run((context) -> {
|
||||
.with(mandatoryProperties()).run((context) -> {
|
||||
DynatraceMeterRegistry registry = spyOnDisposableBean(
|
||||
DynatraceMeterRegistry.class, context);
|
||||
context.close();
|
||||
@@ -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")
|
||||
private <T> T spyOnDisposableBean(Class<T> type,
|
||||
AssertableApplicationContext context) {
|
||||
@@ -139,16 +143,17 @@ public class DynatraceMetricsExportAutoConfigurationTests {
|
||||
|
||||
@Bean
|
||||
public DynatraceConfig customConfig() {
|
||||
return new DynatraceConfig() {
|
||||
|
||||
@Override
|
||||
public String get(String k) {
|
||||
if ("dynatrace.uri".equals(k)) {
|
||||
return "https://dynatrace.example.com";
|
||||
}
|
||||
return null;
|
||||
return (k) -> {
|
||||
if ("dynatrace.uri".equals(k)) {
|
||||
return "https://dynatrace.example.com";
|
||||
}
|
||||
|
||||
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.
|
||||
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.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.duration-units=milliseconds # Base time unit used to report durations.
|
||||
management.metrics.export.ganglia.enabled=true # Whether exporting of metrics to Ganglia is enabled.
|
||||
|
||||
Reference in New Issue
Block a user