Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Aggregation Temporality in Dynatrace Exporter #181

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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