mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-25 19:09:03 +00:00
Adapt to deprecation of support for Dynatrace V1 API
See gh-49111
This commit is contained in:
+7
-3
@@ -174,9 +174,13 @@ management:
|
||||
|
||||
Dynatrace offers two metrics ingest APIs, both of which are implemented for {url-micrometer-docs-implementations}/dynatrace[Micrometer].
|
||||
You can find the Dynatrace documentation on Micrometer metrics ingest {url-dynatrace-docs-shortlink}/micrometer-metrics-ingest[here].
|
||||
|
||||
Configuration properties in the `v1` namespace apply only when exporting to the {url-dynatrace-docs-shortlink}/api-metrics[Timeseries v1 API].
|
||||
Support for the V1 API is deprecated.
|
||||
|
||||
Configuration properties in the `v2` namespace apply only when exporting to the {url-dynatrace-docs-shortlink}/api-metrics-v2-post-datapoints[Metrics v2 API].
|
||||
Note that this integration can export only to either the `v1` or `v2` version of the API at a time, with `v2` being preferred.
|
||||
|
||||
Note that this integration can export only to either the `v1` or `v2` version of the API at a time, with `v2` being strongly recommended due to the deprecation of the v1 API.
|
||||
If the `device-id` (required for v1 but not used in v2) is set in the `v1` namespace, metrics are exported to the `v1` endpoint.
|
||||
Otherwise, `v2` is assumed.
|
||||
|
||||
@@ -264,13 +268,13 @@ management:
|
||||
|
||||
|
||||
[[actuator.metrics.export.dynatrace.v1-api]]
|
||||
==== v1 API (Legacy)
|
||||
==== v1 API (Deprecated)
|
||||
|
||||
The Dynatrace v1 API metrics registry pushes metrics to the configured URI periodically by using the {url-dynatrace-docs-shortlink}/api-metrics[Timeseries v1 API].
|
||||
For backwards-compatibility with existing setups, when `device-id` is set (required for v1, but not used in v2), metrics are exported to the Timeseries v1 endpoint.
|
||||
To export metrics to {url-micrometer-docs-implementations}/dynatrace[Dynatrace], your API token, device ID, and URI must be provided:
|
||||
|
||||
[configprops,yaml]
|
||||
[configprops%novalidate,yaml]
|
||||
----
|
||||
management:
|
||||
dynatrace:
|
||||
|
||||
+10
@@ -21,6 +21,7 @@ import java.util.Map;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
||||
import org.springframework.boot.micrometer.metrics.autoconfigure.export.properties.StepRegistryProperties;
|
||||
|
||||
/**
|
||||
@@ -34,6 +35,7 @@ import org.springframework.boot.micrometer.metrics.autoconfigure.export.properti
|
||||
@ConfigurationProperties("management.dynatrace.metrics.export")
|
||||
public class DynatraceProperties extends StepRegistryProperties {
|
||||
|
||||
@Deprecated(since = "4.1.0", forRemoval = true)
|
||||
private final V1 v1 = new V1();
|
||||
|
||||
private final V2 v2 = new V2();
|
||||
@@ -65,6 +67,7 @@ public class DynatraceProperties extends StepRegistryProperties {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
@Deprecated(since = "4.1.0", forRemoval = true)
|
||||
public V1 getV1() {
|
||||
return this.v1;
|
||||
}
|
||||
@@ -73,6 +76,7 @@ public class DynatraceProperties extends StepRegistryProperties {
|
||||
return this.v2;
|
||||
}
|
||||
|
||||
@Deprecated(since = "4.1.0", forRemoval = true)
|
||||
public static class V1 {
|
||||
|
||||
/**
|
||||
@@ -92,6 +96,8 @@ public class DynatraceProperties extends StepRegistryProperties {
|
||||
*/
|
||||
private String technologyType = "java";
|
||||
|
||||
@DeprecatedConfigurationProperty(reason = "Dynatrace V1 API is deprecated, use the V2 API instead.",
|
||||
since = "4.1.0")
|
||||
public @Nullable String getDeviceId() {
|
||||
return this.deviceId;
|
||||
}
|
||||
@@ -100,6 +106,8 @@ public class DynatraceProperties extends StepRegistryProperties {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
@DeprecatedConfigurationProperty(reason = "Dynatrace V1 API is deprecated, use the V2 API instead.",
|
||||
since = "4.1.0")
|
||||
public @Nullable String getGroup() {
|
||||
return this.group;
|
||||
}
|
||||
@@ -108,6 +116,8 @@ public class DynatraceProperties extends StepRegistryProperties {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
@DeprecatedConfigurationProperty(reason = "Dynatrace V1 API is deprecated, use the V2 API instead.",
|
||||
since = "4.1.0")
|
||||
public String getTechnologyType() {
|
||||
return this.technologyType;
|
||||
}
|
||||
|
||||
+14
-5
@@ -22,7 +22,6 @@ import io.micrometer.dynatrace.DynatraceApiVersion;
|
||||
import io.micrometer.dynatrace.DynatraceConfig;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.boot.micrometer.metrics.autoconfigure.export.dynatrace.DynatraceProperties.V1;
|
||||
import org.springframework.boot.micrometer.metrics.autoconfigure.export.dynatrace.DynatraceProperties.V2;
|
||||
import org.springframework.boot.micrometer.metrics.autoconfigure.export.properties.StepRegistryPropertiesConfigAdapter;
|
||||
|
||||
@@ -45,18 +44,23 @@ class DynatracePropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapt
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public String apiToken() {
|
||||
return obtain(DynatraceProperties::getApiToken, DynatraceConfig.super::apiToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "4.1.0", forRemoval = true)
|
||||
public String deviceId() {
|
||||
return obtain(v1(V1::getDeviceId), DynatraceConfig.super::deviceId);
|
||||
return obtain(v1(DynatraceProperties.V1::getDeviceId), DynatraceConfig.super::deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "4.1.0", forRemoval = true)
|
||||
public String technologyType() {
|
||||
return obtain(v1(V1::getTechnologyType), DynatraceConfig.super::technologyType);
|
||||
return obtain(v1(DynatraceProperties.V1::getTechnologyType), DynatraceConfig.super::technologyType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,11 +69,14 @@ class DynatracePropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapt
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "4.1.0", forRemoval = true)
|
||||
public @Nullable String group() {
|
||||
return get(v1(V1::getGroup), DynatraceConfig.super::group);
|
||||
return get(v1(DynatraceProperties.V1::getGroup), DynatraceConfig.super::group);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
public DynatraceApiVersion apiVersion() {
|
||||
return obtain((properties) -> (properties.getV1().getDeviceId() != null) ? DynatraceApiVersion.V1
|
||||
: DynatraceApiVersion.V2, DynatraceConfig.super::apiVersion);
|
||||
@@ -100,7 +107,9 @@ class DynatracePropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapt
|
||||
return obtain(v2(V2::isExportMeterMetadata), DynatraceConfig.super::exportMeterMetadata);
|
||||
}
|
||||
|
||||
private <V> Getter<DynatraceProperties, V> v1(Getter<V1, V> getter) {
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "4.1.0", forRemoval = true)
|
||||
private <V> Getter<DynatraceProperties, V> v1(Getter<DynatraceProperties.V1, V> getter) {
|
||||
return (properties) -> getter.get(properties.getV1());
|
||||
}
|
||||
|
||||
|
||||
+18
-3
@@ -53,6 +53,8 @@ class DynatracePropertiesConfigAdapterTests
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "4.1.0", forRemoval = true)
|
||||
void whenPropertiesV1DeviceIdIsSetAdapterDeviceIdReturnsIt() {
|
||||
DynatraceProperties properties = new DynatraceProperties();
|
||||
properties.getV1().setDeviceId("dev-1");
|
||||
@@ -60,6 +62,8 @@ class DynatracePropertiesConfigAdapterTests
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "4.1.0", forRemoval = true)
|
||||
void whenPropertiesV1TechnologyTypeIsSetAdapterTechnologyTypeReturnsIt() {
|
||||
DynatraceProperties properties = new DynatraceProperties();
|
||||
properties.getV1().setTechnologyType("tech-1");
|
||||
@@ -67,6 +71,8 @@ class DynatracePropertiesConfigAdapterTests
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "4.1.0", forRemoval = true)
|
||||
void whenPropertiesV1GroupIsSetAdapterGroupReturnsIt() {
|
||||
DynatraceProperties properties = new DynatraceProperties();
|
||||
properties.getV1().setGroup("group-1");
|
||||
@@ -74,6 +80,8 @@ class DynatracePropertiesConfigAdapterTests
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "4.1.0", forRemoval = true)
|
||||
void whenV1DeviceIdIsSetThenAdapterApiVersionIsV1() {
|
||||
DynatraceProperties properties = new DynatraceProperties();
|
||||
properties.getV1().setDeviceId("dev-1");
|
||||
@@ -123,13 +131,20 @@ class DynatracePropertiesConfigAdapterTests
|
||||
DynatraceProperties properties = new DynatraceProperties();
|
||||
assertThat(properties.getApiToken()).isNull();
|
||||
assertThat(properties.getUri()).isNull();
|
||||
assertThat(properties.getV1().getDeviceId()).isNull();
|
||||
assertThat(properties.getV1().getTechnologyType()).isEqualTo("java");
|
||||
assertThat(properties.getV1().getGroup()).isNull();
|
||||
assertThat(properties.getV2().getMetricKeyPrefix()).isNull();
|
||||
assertThat(properties.getV2().isEnrichWithDynatraceMetadata()).isTrue();
|
||||
assertThat(properties.getV2().getDefaultDimensions()).isNull();
|
||||
assertThat(properties.getV2().isUseDynatraceSummaryInstruments()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(forRemoval = true, since = "4.1.0")
|
||||
void v1DefaultValues() {
|
||||
DynatraceProperties properties = new DynatraceProperties();
|
||||
assertThat(properties.getV1().getDeviceId()).isNull();
|
||||
assertThat(properties.getV1().getTechnologyType()).isEqualTo("java");
|
||||
assertThat(properties.getV1().getGroup()).isNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-1
@@ -35,10 +35,18 @@ class DynatracePropertiesTests extends StepRegistryPropertiesTests {
|
||||
DynatraceProperties properties = new DynatraceProperties();
|
||||
DynatraceConfig config = (key) -> null;
|
||||
assertStepRegistryDefaultValues(properties, config);
|
||||
assertThat(properties.getV1().getTechnologyType()).isEqualTo(config.technologyType());
|
||||
assertThat(properties.getV2().isUseDynatraceSummaryInstruments())
|
||||
.isEqualTo(config.useDynatraceSummaryInstruments());
|
||||
assertThat(properties.getV2().isExportMeterMetadata()).isEqualTo(config.exportMeterMetadata());
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
@Deprecated(since = "4.1.0", forRemoval = true)
|
||||
void v1DefaultValuesAreConsistent() {
|
||||
DynatraceProperties properties = new DynatraceProperties();
|
||||
DynatraceConfig config = (key) -> null;
|
||||
assertThat(properties.getV1().getTechnologyType()).isEqualTo(config.technologyType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user