Skip to content

Commit 1a67277

Browse files
committed
Update documentation to use v2 as default
1 parent 8bf3488 commit 1a67277

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

src/docs/implementations/dynatrace.adoc

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ Use the following code in your project to export Micrometer metrics to the https
2121
[source,java]
2222
----
2323
DynatraceConfig dynatraceConfig = new DynatraceConfig() {
24-
@Override
25-
public DynatraceApiVersion apiVersion() {
26-
return DynatraceApiVersion.V2;
27-
}
28-
2924
@Override
3025
@Nullable
3126
public String get(String k) {
@@ -34,8 +29,26 @@ DynatraceConfig dynatraceConfig = new DynatraceConfig() {
3429
}
3530
};
3631
MeterRegistry registry = new DynatraceMeterRegistry(dynatraceConfig, Clock.SYSTEM);
32+
Metrics.addRegistry(registry);
3733
----
3834

35+
It is also possible to specify the exporter version explicitly, which defaults to `v2` unless a deviceId is set:
36+
37+
[source,java]
38+
----
39+
DynatraceConfig dynatraceConfig = new DynatraceConfig() {
40+
@Override
41+
public DynatraceApiVersion apiVersion() {
42+
return DynatraceApiVersion.V2;
43+
}
44+
45+
@Override
46+
@Nullable
47+
public String get(String k) { return null; }
48+
};
49+
----
50+
51+
3952
`DynatraceConfig` is an interface with a set of default methods.
4053
Micrometer's Spring Boot support binds properties prefixed with `management.metrics.export.dynatrace` directly to the `DynatraceConfig`.
4154
This allows configuring the Dynatrace exporter by using the <<bookmark-available-properties, the available properties>>.
@@ -45,7 +58,7 @@ In this default configuration, metrics will be exported to the v2 endpoint.
4558

4659
=== Using a custom endpoint
4760

48-
If no Dynatrace OneAgent is available, both the Dynatrace Metrics API v2 endpoint and an API token have to be specified.
61+
If no Dynatrace OneAgent is available on the host, both the Dynatrace Metrics API v2 endpoint and an API token have to be specified.
4962
The https://www.dynatrace.com/support/help/dynatrace-api/basics/dynatrace-api-authentication/[Dynatrace API token documentation] contains more information on how to create an API token.
5063
The 'Ingest metrics' (`metrics.ingest`) permission is required on the token in order to ingest metrics.
5164
It is recommended to limit scope to only this permission.
@@ -55,6 +68,7 @@ It is recommended to limit scope to only this permission.
5568
DynatraceConfig dynatraceConfig = new DynatraceConfig() {
5669
@Override
5770
public DynatraceApiVersion apiVersion() {
71+
// not strictly required, but makes the code more clear.
5872
return DynatraceApiVersion.V2;
5973
}
6074
@@ -63,6 +77,7 @@ DynatraceConfig dynatraceConfig = new DynatraceConfig() {
6377
// The endpoint of the Dynatrace Metrics API v2 including path, e.g.:
6478
// "https://{your-environment-id}.live.dynatrace.com/api/v2/metrics/ingest".
6579
// Should be read from a secure source and not hard-coded.
80+
// This example shows how it could be read from an environment variable:
6681
String endpoint = System.getenv("DT_METRICS_INGEST_URL");
6782
return endpoint != null ? endpoint : DynatraceConfig.super.uri();
6883
}
@@ -86,9 +101,9 @@ MeterRegistry registry = new DynatraceMeterRegistry(dynatraceConfig, Clock.SYSTE
86101
Metrics.addRegistry(registry);
87102
----
88103

89-
These properties can also be set via the Spring Boot properties file.
104+
These properties can also be set via Spring Boot, using the properties file.
90105
It is possible to reference environment variables using the Spring property placeholder notation here (`${VAR_NAME}`).
91-
When running the Micrometer exporter for Spring Boot, `v2` is used as the default API version.
106+
`v2` is used as the default API version unless a deviceId is set (<<bookmark-apiv1, see below>>).
92107

93108
[source,yml]
94109
----
@@ -105,10 +120,9 @@ management.metrics.export.dynatrace:
105120

106121
=== API v2 [[bookmark-apiv2]]
107122

108-
When the API version is configured to "v2", the registry will send data using the https://www.dynatrace.com/support/help/dynatrace-api/environment-api/metric-v2/[Metrics API v2].
109-
The v2 exporter does not require any properties to be set except for the version.
110-
When running Micrometer without Spring Boot, the default version is `v1` in order to maintain backwards compatibility.
111-
The version is assumed to be `v2` automatically when using Spring Boot, and does not have to be set explicitly in that case.
123+
When the API version is configured to `v2`, the registry will send data using the https://www.dynatrace.com/support/help/dynatrace-api/environment-api/metric-v2/[Metrics API v2].
124+
In order to maintain backwards compatibility, when a `deviceId` is set (which is required for `v1` and not used in `v2`), `v1` is used as the default.
125+
Otherwise, the version defaults to `v2`, and does not have to be set explicitly.
112126
With no endpoint URL and token set, metrics will be exported to the local OneAgent endpoint.
113127
If no OneAgent is running on the target host, it is possible to specify endpoint and token explicitly, in order to export metrics to that specific endpoint.
114128

@@ -219,12 +233,11 @@ DynatraceConfig dynatraceConfig = new DynatraceConfig() {
219233

220234
For more information about the metadata picked up by the Dynatrace metadata enrichment feature, see https://www.dynatrace.com/support/help/how-to-use-dynatrace/metrics/metric-ingestion/ingestion-methods/enrich-metrics/[the Dynatrace documentation].
221235

222-
=== API v1 (Legacy)
236+
=== API v1 (Legacy) [[bookmark-apiv1]]
223237

224238
When the apiVersion is configured to `v1`, the registry will send data using the https://www.dynatrace.com/support/help/dynatrace-api/environment-api/metric-v1/custom-metrics/[Dynatrace Timeseries API v1 for custom metrics].
225-
If no `apiVersion` is specified, it will default to `v1` for backwards compatibility with earlier setups.
226-
When using Spring Boot, `v1` can be turned on by specifying the `device-id` property, which is required for `v1` and not used in `v2`.
227-
Therefore, when running Spring Boot with the `v1` exporter and a configuration with the required `device-id` property, metrics will be exported to the v1 API.
239+
If a `deviceId` is specified, it will default to `v1` for backwards compatibility with earlier setups.
240+
The `device-id` property is required for `v1` and not used in `v2`.
228241
Existing setups will continue to work when updating to newer versions of Micrometer.
229242
The reported metrics will be assigned to https://www.dynatrace.com/support/help/dynatrace-api/environment-api/topology-and-smartscape/custom-device-api/report-custom-device-metric-via-rest-api/[custom devices] in Dynatrace.
230243

0 commit comments

Comments
 (0)