Skip to content

Commit

Permalink
Merge pull request #181 from SAP/fix-dt-otel-temporality
Browse files Browse the repository at this point in the history
Fix Aggregation Temporality in Dynatrace Exporter
  • Loading branch information
KarstenSchnitter authored Jul 15, 2024
2 parents 4a3518b + 44277b5 commit 9732fe3
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.opentelemetry.sdk.common.export.RetryPolicy;
import io.opentelemetry.sdk.metrics.Aggregation;
import io.opentelemetry.sdk.metrics.InstrumentType;
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
import io.opentelemetry.sdk.metrics.export.AggregationTemporalitySelector;
import io.opentelemetry.sdk.metrics.export.DefaultAggregationSelector;
import io.opentelemetry.sdk.metrics.export.MetricExporter;
Expand All @@ -27,6 +28,7 @@ public class DynatraceMetricsExporterProvider implements ConfigurableMetricExpor
public static final String CRED_DYNATRACE_APIURL = "apiurl";
public static final String DT_APIURL_METRICS_SUFFIX = "/v2/otlp/v1/metrics";
private static final Logger LOG = Logger.getLogger(DynatraceMetricsExporterProvider.class.getName());
private static final AggregationTemporalitySelector ALWAYS_DELTA = instrumentType -> AggregationTemporality.DELTA;
private final Function<ConfigProperties, CfService> serviceProvider;

public DynatraceMetricsExporterProvider() {
Expand All @@ -50,7 +52,7 @@ private static Duration getTimeOut(ConfigProperties config) {
private static AggregationTemporalitySelector getAggregationTemporalitySelector(ConfigProperties config) {
String temporalityStr = config.getString("otel.exporter.dynatrace.metrics.temporality.preference");
if (temporalityStr == null) {
return AggregationTemporalitySelector.deltaPreferred();
return ALWAYS_DELTA;
}
AggregationTemporalitySelector temporalitySelector;
switch (temporalityStr.toLowerCase(Locale.ROOT)) {
Expand All @@ -60,6 +62,8 @@ private static AggregationTemporalitySelector getAggregationTemporalitySelector(
return AggregationTemporalitySelector.deltaPreferred();
case "lowmemory":
return AggregationTemporalitySelector.lowMemory();
case "always_delta":
return ALWAYS_DELTA;
default:
throw new ConfigurationException("Unrecognized aggregation temporality: " + temporalityStr);
}
Expand Down

0 comments on commit 9732fe3

Please sign in to comment.