Skip to content

Commit c2f2bde

Browse files
committed
Merge pull request #30637 from joaopgrassi
* pr/30637: Polish "Allow disabling the Dynatrace instruments" Allow disabling the Dynatrace instruments Closes gh-30637
2 parents cd8c64e + 69045e4 commit c2f2bde

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -168,6 +168,12 @@ public static class V2 {
168168
*/
169169
private String metricKeyPrefix;
170170

171+
/**
172+
* Whether to fall back to the built-in micrometer instruments for Timer and
173+
* DistributionSummary.
174+
*/
175+
private boolean useDynatraceSummaryInstruments = true;
176+
171177
public Map<String, String> getDefaultDimensions() {
172178
return this.defaultDimensions;
173179
}
@@ -192,6 +198,14 @@ public void setMetricKeyPrefix(String metricKeyPrefix) {
192198
this.metricKeyPrefix = metricKeyPrefix;
193199
}
194200

201+
public boolean isUseDynatraceSummaryInstruments() {
202+
return this.useDynatraceSummaryInstruments;
203+
}
204+
205+
public void setUseDynatraceSummaryInstruments(boolean useDynatraceSummaryInstruments) {
206+
this.useDynatraceSummaryInstruments = useDynatraceSummaryInstruments;
207+
}
208+
195209
}
196210

197211
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -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: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -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)