Merge pull request #30637 from joaopgrassi
* pr/30637: Polish "Allow disabling the Dynatrace instruments" Allow disabling the Dynatrace instruments Closes gh-30637
This commit is contained in:
commit
c2f2bdea78
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -168,6 +168,12 @@ public class DynatraceProperties extends StepRegistryProperties {
|
||||||
*/
|
*/
|
||||||
private String metricKeyPrefix;
|
private String metricKeyPrefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to fall back to the built-in micrometer instruments for Timer and
|
||||||
|
* DistributionSummary.
|
||||||
|
*/
|
||||||
|
private boolean useDynatraceSummaryInstruments = true;
|
||||||
|
|
||||||
public Map<String, String> getDefaultDimensions() {
|
public Map<String, String> getDefaultDimensions() {
|
||||||
return this.defaultDimensions;
|
return this.defaultDimensions;
|
||||||
}
|
}
|
||||||
|
|
@ -192,6 +198,14 @@ public class DynatraceProperties extends StepRegistryProperties {
|
||||||
this.metricKeyPrefix = metricKeyPrefix;
|
this.metricKeyPrefix = metricKeyPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUseDynatraceSummaryInstruments() {
|
||||||
|
return this.useDynatraceSummaryInstruments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUseDynatraceSummaryInstruments(boolean useDynatraceSummaryInstruments) {
|
||||||
|
this.useDynatraceSummaryInstruments = useDynatraceSummaryInstruments;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -90,6 +90,11 @@ class DynatracePropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapt
|
||||||
return get(v2(V2::isEnrichWithDynatraceMetadata), DynatraceConfig.super::enrichWithDynatraceMetadata);
|
return get(v2(V2::isEnrichWithDynatraceMetadata), DynatraceConfig.super::enrichWithDynatraceMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useDynatraceSummaryInstruments() {
|
||||||
|
return get(v2(V2::isUseDynatraceSummaryInstruments), DynatraceConfig.super::useDynatraceSummaryInstruments);
|
||||||
|
}
|
||||||
|
|
||||||
private <V> Function<DynatraceProperties, V> v1(Function<V1, V> getter) {
|
private <V> Function<DynatraceProperties, V> v1(Function<V1, V> getter) {
|
||||||
return (properties) -> getter.apply(properties.getV1());
|
return (properties) -> getter.apply(properties.getV1());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -125,6 +125,13 @@ class DynatracePropertiesConfigAdapterTests {
|
||||||
assertThat(new DynatracePropertiesConfigAdapter(properties).enrichWithDynatraceMetadata()).isTrue();
|
assertThat(new DynatracePropertiesConfigAdapter(properties).enrichWithDynatraceMetadata()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void whenPropertiesUseDynatraceInstrumentsIsSetAdapterUseDynatraceInstrumentsReturnsIt() {
|
||||||
|
DynatraceProperties properties = new DynatraceProperties();
|
||||||
|
properties.getV2().setUseDynatraceSummaryInstruments(false);
|
||||||
|
assertThat(new DynatracePropertiesConfigAdapter(properties).useDynatraceSummaryInstruments()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenPropertiesDefaultDimensionsIsSetAdapterDefaultDimensionsReturnsIt() {
|
void whenPropertiesDefaultDimensionsIsSetAdapterDefaultDimensionsReturnsIt() {
|
||||||
DynatraceProperties properties = new DynatraceProperties();
|
DynatraceProperties properties = new DynatraceProperties();
|
||||||
|
|
@ -148,6 +155,7 @@ class DynatracePropertiesConfigAdapterTests {
|
||||||
assertThat(properties.getV2().getMetricKeyPrefix()).isNull();
|
assertThat(properties.getV2().getMetricKeyPrefix()).isNull();
|
||||||
assertThat(properties.getV2().isEnrichWithDynatraceMetadata()).isTrue();
|
assertThat(properties.getV2().isEnrichWithDynatraceMetadata()).isTrue();
|
||||||
assertThat(properties.getV2().getDefaultDimensions()).isNull();
|
assertThat(properties.getV2().getDefaultDimensions()).isNull();
|
||||||
|
assertThat(properties.getV2().isUseDynatraceSummaryInstruments()).isTrue();
|
||||||
assertThat(properties.getDeviceId()).isNull();
|
assertThat(properties.getDeviceId()).isNull();
|
||||||
assertThat(properties.getTechnologyType()).isEqualTo("java");
|
assertThat(properties.getTechnologyType()).isEqualTo("java");
|
||||||
assertThat(properties.getGroup()).isNull();
|
assertThat(properties.getGroup()).isNull();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue