diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatraceProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatraceProperties.java index c72ab1a2e9..58d6d13ad4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatraceProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatraceProperties.java @@ -51,6 +51,12 @@ public class DynatraceProperties extends StepRegistryProperties { */ private String uri; + /** + * Group for exported metrics. Used to specify custom device group name in the + * Dynatrace UI. + */ + private String group; + public String getApiToken() { return this.apiToken; } @@ -83,4 +89,12 @@ public class DynatraceProperties extends StepRegistryProperties { this.uri = uri; } + public String getGroup() { + return this.group; + } + + public void setGroup(String group) { + this.group = group; + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatracePropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatracePropertiesConfigAdapter.java index f097e6ddad..4a3a2f5724 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatracePropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatracePropertiesConfigAdapter.java @@ -52,4 +52,9 @@ class DynatracePropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapt return get(DynatraceProperties::getUri, DynatraceConfig.super::uri); } + @Override + public String group() { + return get(DynatraceProperties::getGroup, DynatraceConfig.super::group); + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatracePropertiesConfigAdapterTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatracePropertiesConfigAdapterTests.java index 688873bf63..8a4b25b079 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatracePropertiesConfigAdapterTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/dynatrace/DynatracePropertiesConfigAdapterTests.java @@ -55,4 +55,11 @@ class DynatracePropertiesConfigAdapterTests { assertThat(new DynatracePropertiesConfigAdapter(properties).technologyType()).isEqualTo("tech-1"); } + @Test + void whenPropertiesGroupIsSetAdapterGroupReturnsIt() { + DynatraceProperties properties = new DynatraceProperties(); + properties.setGroup("group-1"); + assertThat(new DynatracePropertiesConfigAdapter(properties).group()).isEqualTo("group-1"); + } + }