diff --git a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/metrics/exporter/OTelMetricsExporterFactory.java b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/metrics/exporter/OTelMetricsExporterFactory.java index 9c548044484fd..a1370e2b50c7c 100644 --- a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/metrics/exporter/OTelMetricsExporterFactory.java +++ b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/metrics/exporter/OTelMetricsExporterFactory.java @@ -21,6 +21,10 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import io.opentelemetry.exporter.logging.LoggingMetricExporter; +import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter; +import io.opentelemetry.sdk.metrics.data.AggregationTemporality; +import io.opentelemetry.sdk.metrics.export.AggregationTemporalitySelector; import io.opentelemetry.sdk.metrics.export.MetricExporter; /** @@ -46,7 +50,16 @@ private OTelMetricsExporterFactory() { */ public static MetricExporter create(Settings settings) { Class<MetricExporter> MetricExporterProviderClass = OTelTelemetrySettings.OTEL_METRICS_EXPORTER_CLASS_SETTING.get(settings); - MetricExporter metricExporter = instantiateExporter(MetricExporterProviderClass); + MetricExporter metricExporter; + if (MetricExporterProviderClass.getName().equals(LoggingMetricExporter.class.getName())) { + metricExporter = LoggingMetricExporter.create(AggregationTemporality.DELTA); + } else if (MetricExporterProviderClass.getName().equals(OtlpGrpcMetricExporter.class.getName())) { + metricExporter = OtlpGrpcMetricExporter.builder() + .setAggregationTemporalitySelector(AggregationTemporalitySelector.deltaPreferred()) + .build(); + } else { + metricExporter = instantiateExporter(MetricExporterProviderClass); + } logger.info("Successfully instantiated the Metrics MetricExporter class {}", MetricExporterProviderClass); return metricExporter; }