1818
1919import java .util .Map ;
2020
21- import io .micrometer .dynatrace .DynatraceApiVersion ;
22-
2321import org .springframework .boot .actuate .autoconfigure .metrics .export .properties .StepRegistryProperties ;
2422import org .springframework .boot .context .properties .ConfigurationProperties ;
23+ import org .springframework .boot .context .properties .DeprecatedConfigurationProperty ;
2524
2625/**
2726 * {@link ConfigurationProperties @ConfigurationProperties} for configuring Dynatrace
3433@ ConfigurationProperties (prefix = "management.metrics.export.dynatrace" )
3534public class DynatraceProperties extends StepRegistryProperties {
3635
37- /**
38- * The Dynatrace metrics API version that metrics should be sent to. Defaults to v1.
39- * Required to define which API is used for export.
40- */
41- private DynatraceApiVersion apiVersion = DynatraceApiVersion .V1 ;
36+ private final V1 v1 = new V1 ();
37+
38+ private final V2 v2 = new V2 ();
4239
4340 /**
4441 * Dynatrace authentication token.
45- *
46- * API v1: required, API v2: optional
4742 */
4843 private String apiToken ;
4944
50- /**
51- * ID of the custom device that is exporting metrics to Dynatrace.
52- *
53- * API v1: required, API v2: not applicable (ignored)
54- */
55- private String deviceId ;
56-
57- /**
58- * Technology type for exported metrics. Used to group metrics under a logical
59- * technology name in the Dynatrace UI.
60- *
61- * API v1: required, API v2: not applicable (ignored)
62- */
63- private String technologyType = "java" ;
64-
6545 /**
6646 * URI to ship metrics to. Should be used for SaaS, self managed instances or to
6747 * en-route through an internal proxy.
68- *
69- * API v1: required, API v2: optional
7048 */
7149 private String uri ;
7250
73- /**
74- * Group for exported metrics. Used to specify custom device group name in the
75- * Dynatrace UI.
76- *
77- * API v1: required, API v2: not applicable (ignored)
78- */
79- private String group ;
80-
81- /**
82- * An optional prefix string that is added to all metrics exported.
83- *
84- * API v1: not applicable (ignored), API v2: optional
85- */
86- private String metricKeyPrefix ;
87-
88- /**
89- * An optional Boolean that allows enabling of the Dynatrace metadata export. On by
90- * default.
91- *
92- * API v1: not applicable (ignored), API v2: optional
93- */
94- private Boolean enrichWithDynatraceMetadata = true ;
95-
96- /**
97- * Optional default dimensions that are added to all metrics in the form of key-value
98- * pairs. These are overwritten by Micrometer tags if they use the same key.
99- *
100- * API v1: not applicable (ignored), API v2: optional
101- */
102- private Map <String , String > defaultDimensions ;
103-
10451 public String getApiToken () {
10552 return this .apiToken ;
10653 }
@@ -109,20 +56,26 @@ public void setApiToken(String apiToken) {
10956 this .apiToken = apiToken ;
11057 }
11158
59+ @ Deprecated
60+ @ DeprecatedConfigurationProperty (replacement = "management.metrics.export.dynatrace.v1.device-id" )
11261 public String getDeviceId () {
113- return this .deviceId ;
62+ return this .v1 . getDeviceId () ;
11463 }
11564
65+ @ Deprecated
11666 public void setDeviceId (String deviceId ) {
117- this .deviceId = deviceId ;
67+ this .v1 . setDeviceId ( deviceId ) ;
11868 }
11969
70+ @ Deprecated
71+ @ DeprecatedConfigurationProperty (replacement = "management.metrics.export.dynatrace.v1.technology-type" )
12072 public String getTechnologyType () {
121- return this .technologyType ;
73+ return this .v1 . getTechnologyType () ;
12274 }
12375
76+ @ Deprecated
12477 public void setTechnologyType (String technologyType ) {
125- this .technologyType = technologyType ;
78+ this .v1 . setTechnologyType ( technologyType ) ;
12679 }
12780
12881 public String getUri () {
@@ -133,44 +86,112 @@ public void setUri(String uri) {
13386 this .uri = uri ;
13487 }
13588
89+ @ Deprecated
90+ @ DeprecatedConfigurationProperty (replacement = "management.metrics.export.dynatrace.v1.group" )
13691 public String getGroup () {
137- return this .group ;
92+ return this .v1 . getGroup () ;
13893 }
13994
95+ @ Deprecated
14096 public void setGroup (String group ) {
141- this .group = group ;
97+ this .v1 . setGroup ( group ) ;
14298 }
14399
144- public String getMetricKeyPrefix () {
145- return this .metricKeyPrefix ;
100+ public V1 getV1 () {
101+ return this .v1 ;
146102 }
147103
148- public void setMetricKeyPrefix ( String metricKeyPrefix ) {
149- this .metricKeyPrefix = metricKeyPrefix ;
104+ public V2 getV2 ( ) {
105+ return this .v2 ;
150106 }
151107
152- public Boolean getEnrichWithDynatraceMetadata () {
153- return this .enrichWithDynatraceMetadata ;
154- }
108+ public static class V1 {
155109
156- public void setEnrichWithDynatraceMetadata (Boolean enrichWithDynatraceMetadata ) {
157- this .enrichWithDynatraceMetadata = enrichWithDynatraceMetadata ;
158- }
110+ /**
111+ * ID of the custom device that is exporting metrics to Dynatrace.
112+ */
113+ private String deviceId ;
159114
160- public Map <String , String > getDefaultDimensions () {
161- return this .defaultDimensions ;
162- }
115+ /**
116+ * Group for exported metrics. Used to specify custom device group name in the
117+ * Dynatrace UI.
118+ */
119+ private String group ;
163120
164- public void setDefaultDimensions (Map <String , String > defaultDimensions ) {
165- this .defaultDimensions = defaultDimensions ;
166- }
121+ /**
122+ * Technology type for exported metrics. Used to group metrics under a logical
123+ * technology name in the Dynatrace UI.
124+ */
125+ private String technologyType = "java" ;
126+
127+ public String getDeviceId () {
128+ return this .deviceId ;
129+ }
130+
131+ public void setDeviceId (String deviceId ) {
132+ this .deviceId = deviceId ;
133+ }
134+
135+ public String getGroup () {
136+ return this .group ;
137+ }
138+
139+ public void setGroup (String group ) {
140+ this .group = group ;
141+ }
142+
143+ public String getTechnologyType () {
144+ return this .technologyType ;
145+ }
146+
147+ public void setTechnologyType (String technologyType ) {
148+ this .technologyType = technologyType ;
149+ }
167150
168- public DynatraceApiVersion getApiVersion () {
169- return this .apiVersion ;
170151 }
171152
172- public void setApiVersion (DynatraceApiVersion apiVersion ) {
173- this .apiVersion = apiVersion ;
153+ public static class V2 {
154+
155+ /**
156+ * Default dimensions that are added to all metrics in the form of key-value
157+ * pairs. These are overwritten by Micrometer tags if they use the same key.
158+ */
159+ private Map <String , String > defaultDimensions ;
160+
161+ /**
162+ * Whether to enable Dynatrace metadata export.
163+ */
164+ private boolean enrichWithDynatraceMetadata = true ;
165+
166+ /**
167+ * Prefix string that is added to all exported metrics.
168+ */
169+ private String metricKeyPrefix ;
170+
171+ public Map <String , String > getDefaultDimensions () {
172+ return this .defaultDimensions ;
173+ }
174+
175+ public void setDefaultDimensions (Map <String , String > defaultDimensions ) {
176+ this .defaultDimensions = defaultDimensions ;
177+ }
178+
179+ public boolean isEnrichWithDynatraceMetadata () {
180+ return this .enrichWithDynatraceMetadata ;
181+ }
182+
183+ public void setEnrichWithDynatraceMetadata (Boolean enrichWithDynatraceMetadata ) {
184+ this .enrichWithDynatraceMetadata = enrichWithDynatraceMetadata ;
185+ }
186+
187+ public String getMetricKeyPrefix () {
188+ return this .metricKeyPrefix ;
189+ }
190+
191+ public void setMetricKeyPrefix (String metricKeyPrefix ) {
192+ this .metricKeyPrefix = metricKeyPrefix ;
193+ }
194+
174195 }
175196
176197}
0 commit comments