Skip to content

Commit 44277b5

Browse files
Fix Aggregation Temporality in Dynatrace Exporter
Dynatrace only accepts "delta" aggregation temporality for counters. The "deltaPreferred" option still uses cumulative temporality for up-and-down-counters. This lets Dynatrace drop the data altogether. This commit will send all counters with delta aggregation temporality. Signed-off-by: Karsten Schnitter <[email protected]>
1 parent 26565dc commit 44277b5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cf-java-logging-support-opentelemetry-agent-extension/src/main/java/com/sap/hcf/cf/logging/opentelemetry/agent/ext/exporter/DynatraceMetricsExporterProvider.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import io.opentelemetry.sdk.common.export.RetryPolicy;
1010
import io.opentelemetry.sdk.metrics.Aggregation;
1111
import io.opentelemetry.sdk.metrics.InstrumentType;
12+
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
1213
import io.opentelemetry.sdk.metrics.export.AggregationTemporalitySelector;
1314
import io.opentelemetry.sdk.metrics.export.DefaultAggregationSelector;
1415
import io.opentelemetry.sdk.metrics.export.MetricExporter;
@@ -27,6 +28,7 @@ public class DynatraceMetricsExporterProvider implements ConfigurableMetricExpor
2728
public static final String CRED_DYNATRACE_APIURL = "apiurl";
2829
public static final String DT_APIURL_METRICS_SUFFIX = "/v2/otlp/v1/metrics";
2930
private static final Logger LOG = Logger.getLogger(DynatraceMetricsExporterProvider.class.getName());
31+
private static final AggregationTemporalitySelector ALWAYS_DELTA = instrumentType -> AggregationTemporality.DELTA;
3032
private final Function<ConfigProperties, CfService> serviceProvider;
3133

3234
public DynatraceMetricsExporterProvider() {
@@ -50,7 +52,7 @@ private static Duration getTimeOut(ConfigProperties config) {
5052
private static AggregationTemporalitySelector getAggregationTemporalitySelector(ConfigProperties config) {
5153
String temporalityStr = config.getString("otel.exporter.dynatrace.metrics.temporality.preference");
5254
if (temporalityStr == null) {
53-
return AggregationTemporalitySelector.deltaPreferred();
55+
return ALWAYS_DELTA;
5456
}
5557
AggregationTemporalitySelector temporalitySelector;
5658
switch (temporalityStr.toLowerCase(Locale.ROOT)) {
@@ -60,6 +62,8 @@ private static AggregationTemporalitySelector getAggregationTemporalitySelector(
6062
return AggregationTemporalitySelector.deltaPreferred();
6163
case "lowmemory":
6264
return AggregationTemporalitySelector.lowMemory();
65+
case "always_delta":
66+
return ALWAYS_DELTA;
6367
default:
6468
throw new ConfigurationException("Unrecognized aggregation temporality: " + temporalityStr);
6569
}

0 commit comments

Comments
 (0)