Skip to content

Commit

Permalink
Make AggregationTemporality configurable for OtlpInMemoryMetricExporter
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrdom committed Feb 24, 2023
1 parent ba9df3f commit 231b5dc
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,28 @@
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Logger;

import static java.util.logging.Level.CONFIG;

class OtlpInMemoryMetricExporter implements MetricExporter {

private static final Logger logger = Logger.getLogger(OtlpInMemoryMetricExporter.class.getName());

private final Queue<byte[]> collectedRequests = new ConcurrentLinkedQueue<>();

private final AggregationTemporality aggregationTemporality;

OtlpInMemoryMetricExporter() {
String temporalityProperty = System.getProperty("otel.javaagent.testing.exporter.temporality");
if (temporalityProperty == null) {
aggregationTemporality = AggregationTemporality.DELTA;
} else {
aggregationTemporality = AggregationTemporality.valueOf(temporalityProperty.toUpperCase());
}
logger.log(CONFIG, "Setting aggregation temporality to {0}", aggregationTemporality.toString());
}

List<byte[]> getCollectedExportRequests() {
return new ArrayList<>(collectedRequests);
}
Expand All @@ -34,7 +51,7 @@ void reset() {

@Override
public AggregationTemporality getAggregationTemporality(InstrumentType instrumentType) {
return AggregationTemporality.DELTA;
return aggregationTemporality;
}

@Override
Expand Down

0 comments on commit 231b5dc

Please sign in to comment.