diff --git a/plugins/telemetry-otel/build.gradle b/plugins/telemetry-otel/build.gradle index 66d172e3dc7f3..e0f0f5b601e96 100644 --- a/plugins/telemetry-otel/build.gradle +++ b/plugins/telemetry-otel/build.gradle @@ -28,6 +28,7 @@ dependencies { api "io.opentelemetry:opentelemetry-sdk-trace:${versions.opentelemetry}" api "io.opentelemetry:opentelemetry-sdk-metrics:${versions.opentelemetry}" api "io.opentelemetry:opentelemetry-exporter-logging:${versions.opentelemetry}" + api "io.opentelemetry:opentelemetry-exporter-logging-otlp:${versions.opentelemetry}" api "io.opentelemetry.semconv:opentelemetry-semconv:${versions.opentelemetrysemconv}" api "io.opentelemetry:opentelemetry-sdk-logs:${versions.opentelemetry}" api "io.opentelemetry:opentelemetry-exporter-otlp:${versions.opentelemetry}" diff --git a/plugins/telemetry-otel/config/telemetry-otel/log4j2.properties b/plugins/telemetry-otel/config/telemetry-otel/log4j2.properties index 8dec1119eec66..d088bd75a5fb7 100644 --- a/plugins/telemetry-otel/config/telemetry-otel/log4j2.properties +++ b/plugins/telemetry-otel/config/telemetry-otel/log4j2.properties @@ -41,7 +41,7 @@ appender.metrics.strategy.type = DefaultRolloverStrategy appender.metrics.strategy.max = 4 -logger.metrics_exporter.name = io.opentelemetry.exporter.logging.LoggingMetricExporter +logger.metrics_exporter.name = io.opentelemetry.exporter.logging.OtlpJsonLoggingMetricExporter logger.metrics_exporter.level = INFO logger.metrics_exporter.appenderRef.tracing.ref = metrics logger.metrics_exporter.additivity = false diff --git a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/OTelTelemetrySettings.java b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/OTelTelemetrySettings.java index 95ce6918fcb70..6a586bbe95ff2 100644 --- a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/OTelTelemetrySettings.java +++ b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/OTelTelemetrySettings.java @@ -23,7 +23,7 @@ import java.util.Arrays; import java.util.List; -import io.opentelemetry.exporter.logging.LoggingMetricExporter; +import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingMetricExporter; import io.opentelemetry.exporter.logging.LoggingSpanExporter; import io.opentelemetry.sdk.metrics.export.MetricExporter; import io.opentelemetry.sdk.trace.export.SpanExporter; @@ -99,7 +99,7 @@ private OTelTelemetrySettings() {} @SuppressWarnings({ "unchecked", "removal" }) public static final Setting> OTEL_METRICS_EXPORTER_CLASS_SETTING = new Setting<>( "telemetry.otel.metrics.exporter.class", - LoggingMetricExporter.class.getName(), + OtlpJsonLoggingMetricExporter.class.getName(), className -> { // Check we ourselves are not being called by unprivileged code. SpecialPermission.check(); diff --git a/plugins/telemetry-otel/src/test/java/org/opensearch/telemetry/metrics/exporter/OTelMetricsExporterFactoryTests.java b/plugins/telemetry-otel/src/test/java/org/opensearch/telemetry/metrics/exporter/OTelMetricsExporterFactoryTests.java index e68da030bfb52..aa0ec7e50ec9e 100644 --- a/plugins/telemetry-otel/src/test/java/org/opensearch/telemetry/metrics/exporter/OTelMetricsExporterFactoryTests.java +++ b/plugins/telemetry-otel/src/test/java/org/opensearch/telemetry/metrics/exporter/OTelMetricsExporterFactoryTests.java @@ -8,11 +8,12 @@ package org.opensearch.telemetry.metrics.exporter; +import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingMetricExporter; import org.opensearch.common.settings.Settings; import org.opensearch.telemetry.OTelTelemetrySettings; import org.opensearch.test.OpenSearchTestCase; -import io.opentelemetry.exporter.logging.LoggingMetricExporter; +import io.opentelemetry.exporter.logging.OtlpJsonLoggingMetricExporter; import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter; import io.opentelemetry.sdk.metrics.export.MetricExporter; @@ -21,18 +22,18 @@ public class OTelMetricsExporterFactoryTests extends OpenSearchTestCase { public void testMetricsExporterDefault() { Settings settings = Settings.builder().build(); MetricExporter metricExporter = OTelMetricsExporterFactory.create(settings); - assertTrue(metricExporter instanceof LoggingMetricExporter); + assertTrue(metricExporter instanceof OtlpJsonLoggingMetricExporter); } public void testMetricsExporterLogging() { Settings settings = Settings.builder() .put( OTelTelemetrySettings.OTEL_METRICS_EXPORTER_CLASS_SETTING.getKey(), - "io.opentelemetry.exporter.logging.LoggingMetricExporter" + "io.opentelemetry.exporter.logging.OtlpJsonLoggingMetricExporter" ) .build(); MetricExporter metricExporter = OTelMetricsExporterFactory.create(settings); - assertTrue(metricExporter instanceof LoggingMetricExporter); + assertTrue(metricExporter instanceof OtlpJsonLoggingMetricExporter); } public void testMetricExporterInvalid() {