Skip to content

Commit 7a05faf

Browse files
pirgeosnicoll
authored andcommitted
Allow disabling the Dynatrace instruments
Since Micrometer version 1.9.0, the Dynatrace registry uses specialized instruments by default, which ensures data is exported in an optimal format. By using this new flag, users can switch back to the previous behavior, which uses the original instruments from Micrometer. See gh-30637
1 parent cd8c64e commit 7a05faf

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ public static class V2 {
168168
*/
169169
private String metricKeyPrefix;
170170

171+
/**
172+
* Since version 1.9.0 of Micrometer, the Dynatrace registry uses specialized
173+
* instruments to make sure data is exported in an optimal format. This behavior
174+
* is the new default. This toggle allows switching back to the original
175+
* implementation.
176+
*/
177+
private boolean useDynatraceSummaryInstruments = true;
178+
171179
public Map<String, String> getDefaultDimensions() {
172180
return this.defaultDimensions;
173181
}
@@ -192,6 +200,14 @@ public void setMetricKeyPrefix(String metricKeyPrefix) {
192200
this.metricKeyPrefix = metricKeyPrefix;
193201
}
194202

203+
public boolean isUseDynatraceSummaryInstruments() {
204+
return this.useDynatraceSummaryInstruments;
205+
}
206+
207+
public void setUseDynatraceSummaryInstruments(boolean useDynatraceSummaryInstruments) {
208+
this.useDynatraceSummaryInstruments = useDynatraceSummaryInstruments;
209+
}
210+
195211
}
196212

197213
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public boolean enrichWithDynatraceMetadata() {
9090
return get(v2(V2::isEnrichWithDynatraceMetadata), DynatraceConfig.super::enrichWithDynatraceMetadata);
9191
}
9292

93+
@Override
94+
public boolean useDynatraceSummaryInstruments() {
95+
return get(v2(V2::isUseDynatraceSummaryInstruments), DynatraceConfig.super::useDynatraceSummaryInstruments);
96+
}
97+
9398
private <V> Function<DynatraceProperties, V> v1(Function<V1, V> getter) {
9499
return (properties) -> getter.apply(properties.getV1());
95100
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ void whenPropertiesEnrichWithOneAgentMetadataIsSetAdapterEnrichWithOneAgentMetad
125125
assertThat(new DynatracePropertiesConfigAdapter(properties).enrichWithDynatraceMetadata()).isTrue();
126126
}
127127

128+
@Test
129+
void whenPropertiesUseDynatraceInstrumentsIsSetAdapterUseDynatraceInstrumentsReturnsIt() {
130+
DynatraceProperties properties = new DynatraceProperties();
131+
properties.getV2().setUseDynatraceSummaryInstruments(false);
132+
assertThat(new DynatracePropertiesConfigAdapter(properties).useDynatraceSummaryInstruments()).isFalse();
133+
}
134+
128135
@Test
129136
void whenPropertiesDefaultDimensionsIsSetAdapterDefaultDimensionsReturnsIt() {
130137
DynatraceProperties properties = new DynatraceProperties();
@@ -148,6 +155,7 @@ void defaultValues() {
148155
assertThat(properties.getV2().getMetricKeyPrefix()).isNull();
149156
assertThat(properties.getV2().isEnrichWithDynatraceMetadata()).isTrue();
150157
assertThat(properties.getV2().getDefaultDimensions()).isNull();
158+
assertThat(properties.getV2().isUseDynatraceSummaryInstruments()).isTrue();
151159
assertThat(properties.getDeviceId()).isNull();
152160
assertThat(properties.getTechnologyType()).isEqualTo("java");
153161
assertThat(properties.getGroup()).isNull();

0 commit comments

Comments
 (0)