diff --git a/sdk-extensions/autoconfigure/README.md b/sdk-extensions/autoconfigure/README.md index a39000c16b9..a6c18f46721 100644 --- a/sdk-extensions/autoconfigure/README.md +++ b/sdk-extensions/autoconfigure/README.md @@ -54,7 +54,7 @@ The following configuration properties are common to all exporters: |-----------------------|-----------------------|----------------------------------------------------------------------------------------------------------------------------| | otel.traces.exporter | OTEL_TRACES_EXPORTER | List of exporters to be used for tracing, separated by commas. Default is `otlp`. `none` means no autoconfigured exporter. | | otel.metrics.exporter | OTEL_METRICS_EXPORTER | List of exporters to be used for metrics, separated by commas. Default is `otlp`. `none` means no autoconfigured exporter. | -| otel.logs.exporter | OTEL_LOGS_EXPORTER | List of exporters to be used for logging, separated by commas. Default is `none`. | +| otel.logs.exporter | OTEL_LOGS_EXPORTER | List of exporters to be used for logging, separated by commas. Default is `otlp`. `none` means no autoconfigured exporter. | ### OTLP exporter (span, metric, and log exporters) @@ -64,7 +64,7 @@ The [OpenTelemetry Protocol (OTLP)](https://github.com/open-telemetry/openteleme |----------------------------------------------------------|----------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | otel.traces.exporter=otlp (default) | OTEL_TRACES_EXPORTER=otlp | Select the OpenTelemetry exporter for tracing (default) | | otel.metrics.exporter=otlp (default) | OTEL_METRICS_EXPORTER=otlp | Select the OpenTelemetry exporter for metrics (default) | -| otel.logs.exporter=otlp | OTEL_LOGS_EXPORTER=otlp | Select the OpenTelemetry exporter for logs | +| otel.logs.exporter=otlp (default) | OTEL_LOGS_EXPORTER=otlp | Select the OpenTelemetry exporter for logs (default) | | otel.exporter.otlp.endpoint | OTEL_EXPORTER_OTLP_ENDPOINT | The OTLP traces, metrics, and logs endpoint to connect to. Must be a URL with a scheme of either `http` or `https` based on the use of TLS. If protocol is `http/protobuf` the version and signal will be appended to the path (e.g. `v1/traces`, `v1/metrics`, or `v1/logs`). Default is `http://localhost:4317` when protocol is `grpc`, and `http://localhost:4318/v1/{signal}` when protocol is `http/protobuf`. | | otel.exporter.otlp.traces.endpoint | OTEL_EXPORTER_OTLP_TRACES_ENDPOINT | The OTLP traces endpoint to connect to. Must be a URL with a scheme of either `http` or `https` based on the use of TLS. Default is `http://localhost:4317` when protocol is `grpc`, and `http://localhost:4318/v1/traces` when protocol is `http/protobuf`. | | otel.exporter.otlp.metrics.endpoint | OTEL_EXPORTER_OTLP_METRICS_ENDPOINT | The OTLP metrics endpoint to connect to. Must be a URL with a scheme of either `http` or `https` based on the use of TLS. Default is `http://localhost:4317` when protocol is `grpc`, and `http://localhost:4318/v1/metrics` when protocol is `http/protobuf`. | diff --git a/sdk-extensions/autoconfigure/build.gradle.kts b/sdk-extensions/autoconfigure/build.gradle.kts index a45be6ed08e..48e86ae0712 100644 --- a/sdk-extensions/autoconfigure/build.gradle.kts +++ b/sdk-extensions/autoconfigure/build.gradle.kts @@ -77,7 +77,6 @@ testing { targets { all { testTask { - environment("OTEL_LOGS_EXPORTER", "otlp") environment("OTEL_RESOURCE_ATTRIBUTES", "service.name=test,cat=meow") environment("OTEL_PROPAGATORS", "tracecontext,baggage,b3,b3multi,jaeger,ottrace,test") environment("OTEL_EXPORTER_OTLP_HEADERS", "cat=meow,dog=bark") diff --git a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfiguration.java b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfiguration.java index a712ee30397..da3edc42122 100644 --- a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfiguration.java +++ b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfiguration.java @@ -38,36 +38,39 @@ static Map configureLogRecordExporters( logRecordExporterCustomizer, List closeables) { Set exporterNames = DefaultConfigProperties.getSet(config, "otel.logs.exporter"); - - // Default to no exporter - if (exporterNames.isEmpty()) { - exporterNames = Collections.singleton(EXPORTER_NONE); - } - if (exporterNames.contains(EXPORTER_NONE)) { if (exporterNames.size() > 1) { throw new ConfigurationException( "otel.logs.exporter contains " + EXPORTER_NONE + " along with other exporters"); } - return Collections.emptyMap(); + LogRecordExporter noop = LogRecordExporter.composite(); + LogRecordExporter customized = logRecordExporterCustomizer.apply(noop, config); + if (customized == noop) { + return Collections.emptyMap(); + } + closeables.add(customized); + return Collections.singletonMap(EXPORTER_NONE, customized); + } + + if (exporterNames.isEmpty()) { + exporterNames = Collections.singleton("otlp"); } NamedSpiManager spiExportersManager = logRecordExporterSpiManager(config, serviceClassLoader); - Map exportersByName = new HashMap<>(); - for (String name : exporterNames) { - LogRecordExporter logRecordExporter = configureExporter(name, spiExportersManager); + Map map = new HashMap<>(); + for (String exporterName : exporterNames) { + LogRecordExporter logRecordExporter = configureExporter(exporterName, spiExportersManager); closeables.add(logRecordExporter); LogRecordExporter customizedLogRecordExporter = logRecordExporterCustomizer.apply(logRecordExporter, config); if (customizedLogRecordExporter != logRecordExporter) { closeables.add(customizedLogRecordExporter); } - exportersByName.put(name, customizedLogRecordExporter); + map.put(exporterName, customizedLogRecordExporter); } - - return Collections.unmodifiableMap(exportersByName); + return Collections.unmodifiableMap(map); } // Visible for testing diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LoggerProviderConfigurationTest.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LoggerProviderConfigurationTest.java index 06918251a63..c669d8cd177 100644 --- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LoggerProviderConfigurationTest.java +++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LoggerProviderConfigurationTest.java @@ -37,13 +37,12 @@ class LoggerProviderConfigurationTest { @Test void configureLoggerProvider() { - Map properties = Collections.singletonMap("otel.logs.exporter", "otlp"); List closeables = new ArrayList<>(); SdkLoggerProviderBuilder builder = SdkLoggerProvider.builder(); LoggerProviderConfiguration.configureLoggerProvider( builder, - DefaultConfigProperties.createForTest(properties), + DefaultConfigProperties.createForTest(Collections.emptyMap()), LoggerProviderConfiguration.class.getClassLoader(), MeterProvider.noop(), (a, unused) -> a, diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/metric/viewconfig/ViewConfigCustomizerTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/metric/viewconfig/ViewConfigCustomizerTest.java index 15b62d748f2..f9344f7327a 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/metric/viewconfig/ViewConfigCustomizerTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/metric/viewconfig/ViewConfigCustomizerTest.java @@ -36,6 +36,8 @@ void customizeMeterProvider_Spi() { "none", "otel.metrics.exporter", "none", + "otel.logs.exporter", + "none", "otel.experimental.metrics.view.config", "classpath:/view-config-customizer-test.yaml")) .addMeterProviderCustomizer(