From 7e5897066c9118cc216cee02489f6660c893e1f6 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Wed, 5 Nov 2025 12:03:50 +0100 Subject: [PATCH] Rename management.opentelemetry.logging.export properties They are now under 'management.opentelemetry.logging.export.otlp.*'. Closes gh-47954 --- .../reference/pages/actuator/loggers.adoc | 3 +- .../logging/OtlpLoggingAutoConfiguration.java | 1 - .../logging/OtlpLoggingConfigurations.java | 8 ++++-- .../logging/OtlpLoggingProperties.java | 2 +- ...itional-spring-configuration-metadata.json | 20 ++++++------- ...gingAutoConfigurationIntegrationTests.java | 10 ++++--- .../OtlpLoggingAutoConfigurationTests.java | 28 +++++++++---------- 7 files changed, 38 insertions(+), 34 deletions(-) diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/loggers.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/loggers.adoc index b061a87c5b3..07f0a500df4 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/loggers.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/loggers.adoc @@ -45,7 +45,8 @@ management: opentelemetry: logging: export: - endpoint: "https://otlp.example.com:4318/v1/logs" + otlp: + endpoint: "https://otlp.example.com:4318/v1/logs" ---- NOTE: The OpenTelemetry Logback appender and Log4j appender are not part of Spring Boot. diff --git a/module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfiguration.java b/module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfiguration.java index 009677e12da..da4bd279cc5 100644 --- a/module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfiguration.java +++ b/module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfiguration.java @@ -36,7 +36,6 @@ import org.springframework.context.annotation.Import; */ @AutoConfiguration @ConditionalOnClass({ ConditionalOnEnabledLoggingExport.class, OpenTelemetry.class, SdkLoggerProvider.class }) -@ConditionalOnEnabledLoggingExport("opentelemetry") @EnableConfigurationProperties(OtlpLoggingProperties.class) @Import({ ConnectionDetails.class, Exporters.class }) public final class OtlpLoggingAutoConfiguration { diff --git a/module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingConfigurations.java b/module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingConfigurations.java index 20b3272af47..5d4ecec61d0 100644 --- a/module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingConfigurations.java +++ b/module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingConfigurations.java @@ -25,6 +25,7 @@ import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter; import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder; import org.springframework.beans.factory.ObjectProvider; +import org.springframework.boot.actuate.autoconfigure.logging.ConditionalOnEnabledLoggingExport; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -46,7 +47,7 @@ final class OtlpLoggingConfigurations { @Bean @ConditionalOnMissingBean - @ConditionalOnProperty("management.opentelemetry.logging.export.endpoint") + @ConditionalOnProperty("management.opentelemetry.logging.export.otlp.endpoint") PropertiesOtlpLoggingConnectionDetails openTelemetryLoggingConnectionDetails(OtlpLoggingProperties properties) { return new PropertiesOtlpLoggingConnectionDetails(properties); } @@ -80,10 +81,11 @@ final class OtlpLoggingConfigurations { @ConditionalOnClass(OtlpHttpLogRecordExporter.class) @ConditionalOnMissingBean({ OtlpGrpcLogRecordExporter.class, OtlpHttpLogRecordExporter.class }) @ConditionalOnBean(OtlpLoggingConnectionDetails.class) + @ConditionalOnEnabledLoggingExport("otlp") static class Exporters { @Bean - @ConditionalOnProperty(name = "management.opentelemetry.logging.export.transport", havingValue = "http", + @ConditionalOnProperty(name = "management.opentelemetry.logging.export.otlp.transport", havingValue = "http", matchIfMissing = true) OtlpHttpLogRecordExporter otlpHttpLogRecordExporter(OtlpLoggingProperties properties, OtlpLoggingConnectionDetails connectionDetails, ObjectProvider meterProvider) { @@ -98,7 +100,7 @@ final class OtlpLoggingConfigurations { } @Bean - @ConditionalOnProperty(name = "management.opentelemetry.logging.export.transport", havingValue = "grpc") + @ConditionalOnProperty(name = "management.opentelemetry.logging.export.otlp.transport", havingValue = "grpc") OtlpGrpcLogRecordExporter otlpGrpcLogRecordExporter(OtlpLoggingProperties properties, OtlpLoggingConnectionDetails connectionDetails, ObjectProvider meterProvider) { OtlpGrpcLogRecordExporterBuilder builder = OtlpGrpcLogRecordExporter.builder() diff --git a/module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingProperties.java b/module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingProperties.java index 720ad2b1034..189d485aee1 100644 --- a/module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingProperties.java +++ b/module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingProperties.java @@ -30,7 +30,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * @author Jonatan Ivanov * @since 4.0.0 */ -@ConfigurationProperties("management.opentelemetry.logging.export") +@ConfigurationProperties("management.opentelemetry.logging.export.otlp") public class OtlpLoggingProperties { /** diff --git a/module/spring-boot-opentelemetry/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/module/spring-boot-opentelemetry/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 316a51d4f84..f1666b8738d 100644 --- a/module/spring-boot-opentelemetry/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/module/spring-boot-opentelemetry/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -7,12 +7,12 @@ "description": "Whether auto-configuration of logging is enabled to export logs.", "defaultValue": true, "deprecation": { - "replacement": "management.opentelemetry.logging.export.enabled", + "replacement": "management.logging.export.otlp.enabled", "level": "error" } }, { - "name": "management.opentelemetry.logging.export.enabled", + "name": "management.logging.export.otlp.enabled", "type": "java.lang.Boolean", "description": "Whether auto-configuration of logging is enabled to export logs over OTLP." }, @@ -21,7 +21,7 @@ "type": "org.springframework.boot.opentelemetry.actuate.autoconfigure.logging.OpenTelemetryLoggingExportProperties", "sourceType": "org.springframework.boot.opentelemetry.actuate.autoconfigure.logging.OpenTelemetryLoggingExportProperties", "deprecation": { - "replacement": "management.opentelemetry.logging.export", + "replacement": "management.opentelemetry.logging.export.otlp", "level": "error" } }, @@ -32,7 +32,7 @@ "sourceType": "org.springframework.boot.opentelemetry.actuate.autoconfigure.logging.OpenTelemetryLoggingExportProperties", "defaultValue": "none", "deprecation": { - "replacement": "management.opentelemetry.logging.export.compression", + "replacement": "management.opentelemetry.logging.export.otlp.compression", "level": "error" } }, @@ -43,7 +43,7 @@ "sourceType": "org.springframework.boot.opentelemetry.actuate.autoconfigure.logging.OpenTelemetryLoggingExportProperties", "defaultValue": "10s", "deprecation": { - "replacement": "management.opentelemetry.logging.export.connect-timeout", + "replacement": "management.opentelemetry.logging.export.otlp.connect-timeout", "level": "error" } }, @@ -53,7 +53,7 @@ "description": "URL to the OTel collector's HTTP API.", "sourceType": "org.springframework.boot.opentelemetry.actuate.autoconfigure.logging.OpenTelemetryLoggingExportProperties", "deprecation": { - "replacement": "management.opentelemetry.logging.export.endpoint", + "replacement": "management.opentelemetry.logging.export.otlp.endpoint", "level": "error" } }, @@ -62,7 +62,7 @@ "type": "java.lang.Boolean", "description": "Whether auto-configuration of logging is enabled to export OTLP logs.", "deprecation": { - "replacement": "management.opentelemetry.logging.export.enabled", + "replacement": "management.logging.export.otlp.enabled", "level": "error" } }, @@ -72,7 +72,7 @@ "description": "Custom HTTP headers you want to pass to the collector, for example auth headers.", "sourceType": "org.springframework.boot.opentelemetry.actuate.autoconfigure.logging.OpenTelemetryLoggingExportProperties", "deprecation": { - "replacement": "management.opentelemetry.logging.export.headers", + "replacement": "management.opentelemetry.logging.export.otlp.headers", "level": "error" } }, @@ -83,7 +83,7 @@ "sourceType": "org.springframework.boot.opentelemetry.actuate.autoconfigure.logging.OpenTelemetryLoggingExportProperties", "defaultValue": "10s", "deprecation": { - "replacement": "management.opentelemetry.logging.export.timeout", + "replacement": "management.opentelemetry.logging.export.otlp.timeout", "level": "error" } }, @@ -94,7 +94,7 @@ "sourceType": "org.springframework.boot.opentelemetry.actuate.autoconfigure.logging.OpenTelemetryLoggingExportProperties", "defaultValue": "http", "deprecation": { - "replacement": "management.opentelemetry.logging.export.transport", + "replacement": "management.opentelemetry.logging.export.otlp.transport", "level": "error" } } diff --git a/module/spring-boot-opentelemetry/src/test/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfigurationIntegrationTests.java b/module/spring-boot-opentelemetry/src/test/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfigurationIntegrationTests.java index 56d54d60640..ebaed5dd629 100644 --- a/module/spring-boot-opentelemetry/src/test/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfigurationIntegrationTests.java +++ b/module/spring-boot-opentelemetry/src/test/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfigurationIntegrationTests.java @@ -48,7 +48,7 @@ class OtlpLoggingAutoConfigurationIntegrationTests { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withPropertyValues("spring.application.name=otlp-logs-test", - "management.opentelemetry.logging.export.headers.Authorization=Bearer my-token") + "management.opentelemetry.logging.export.otlp.headers.Authorization=Bearer my-token") .withConfiguration( AutoConfigurations.of(OpenTelemetrySdkAutoConfiguration.class, OtlpLoggingAutoConfiguration.class)); @@ -68,7 +68,7 @@ class OtlpLoggingAutoConfigurationIntegrationTests { void httpLogRecordExporterShouldUseProtobufAndNoCompressionByDefault() { this.mockWebServer.enqueue(new MockResponse()); this.contextRunner - .withPropertyValues("management.opentelemetry.logging.export.endpoint=http://localhost:%d/v1/logs" + .withPropertyValues("management.opentelemetry.logging.export.otlp.endpoint=http://localhost:%d/v1/logs" .formatted(this.mockWebServer.getPort())) .run((context) -> { logMessage(context); @@ -88,8 +88,10 @@ class OtlpLoggingAutoConfigurationIntegrationTests { void httpLogRecordExporterCanBeConfiguredToUseGzipCompression() { this.mockWebServer.enqueue(new MockResponse()); this.contextRunner - .withPropertyValues("management.opentelemetry.logging.export.endpoint=http://localhost:%d/v1/logs" - .formatted(this.mockWebServer.getPort()), "management.opentelemetry.logging.export.compression=gzip") + .withPropertyValues( + "management.opentelemetry.logging.export.otlp.endpoint=http://localhost:%d/v1/logs" + .formatted(this.mockWebServer.getPort()), + "management.opentelemetry.logging.export.otlp.compression=gzip") .run((context) -> { logMessage(context); RecordedRequest request = this.mockWebServer.takeRequest(10, TimeUnit.SECONDS); diff --git a/module/spring-boot-opentelemetry/src/test/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfigurationTests.java b/module/spring-boot-opentelemetry/src/test/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfigurationTests.java index 102c806a34b..380ff6e3dfb 100644 --- a/module/spring-boot-opentelemetry/src/test/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfigurationTests.java +++ b/module/spring-boot-opentelemetry/src/test/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfigurationTests.java @@ -77,7 +77,7 @@ class OtlpLoggingAutoConfigurationTests { @Test void whenHasEndpointPropertyProvidesBeans() { this.contextRunner - .withPropertyValues("management.opentelemetry.logging.export.endpoint=http://localhost:4318/v1/logs") + .withPropertyValues("management.opentelemetry.logging.export.otlp.endpoint=http://localhost:4318/v1/logs") .run((context) -> { assertThat(context).hasSingleBean(OtlpLoggingConnectionDetails.class); OtlpLoggingConnectionDetails connectionDetails = context.getBean(OtlpLoggingConnectionDetails.class); @@ -98,10 +98,10 @@ class OtlpLoggingAutoConfigurationTests { @Test void whenOpenTelemetryLoggingExportEnabledPropertyIsFalseProvidesExpectedBeans() { this.contextRunner - .withPropertyValues("management.opentelemetry.logging.export.enabled=false", - "management.opentelemetry.logging.export.endpoint=http://localhost:4318/v1/logs") + .withPropertyValues("management.logging.export.otlp.enabled=false", + "management.opentelemetry.logging.export.otlp.endpoint=http://localhost:4318/v1/logs") .run((context) -> { - assertThat(context).doesNotHaveBean(OtlpLoggingConnectionDetails.class); + assertThat(context).hasSingleBean(OtlpLoggingConnectionDetails.class); assertThat(context).doesNotHaveBean(LogRecordExporter.class); }); } @@ -110,9 +110,9 @@ class OtlpLoggingAutoConfigurationTests { void whenLoggingExportEnabledPropertyIsFalseNoProvideExpectedBeans() { this.contextRunner .withPropertyValues("management.logging.export.enabled=false", - "management.opentelemetry.logging.export.endpoint=http://localhost:4318/v1/logs") + "management.opentelemetry.logging.export.otlp.endpoint=http://localhost:4318/v1/logs") .run((context) -> { - assertThat(context).doesNotHaveBean(OtlpLoggingConnectionDetails.class); + assertThat(context).hasSingleBean(OtlpLoggingConnectionDetails.class); assertThat(context).doesNotHaveBean(LogRecordExporter.class); }); } @@ -146,7 +146,7 @@ class OtlpLoggingAutoConfigurationTests { @Test void whenHasNoTransportPropertySetUsesHttpExporter() { this.contextRunner - .withPropertyValues("management.opentelemetry.logging.export.endpoint=http://localhost:4318/v1/logs") + .withPropertyValues("management.opentelemetry.logging.export.otlp.endpoint=http://localhost:4318/v1/logs") .run((context) -> { assertThat(context).hasSingleBean(OtlpHttpLogRecordExporter.class); assertThat(context).hasSingleBean(LogRecordExporter.class); @@ -157,8 +157,8 @@ class OtlpLoggingAutoConfigurationTests { @Test void whenHasTransportPropertySetToHttpUsesHttpExporter() { this.contextRunner - .withPropertyValues("management.opentelemetry.logging.export.endpoint=http://localhost:4318/v1/logs", - "management.opentelemetry.logging.export.transport=http") + .withPropertyValues("management.opentelemetry.logging.export.otlp.endpoint=http://localhost:4318/v1/logs", + "management.opentelemetry.logging.export.otlp.transport=http") .run((context) -> { assertThat(context).hasSingleBean(OtlpHttpLogRecordExporter.class); assertThat(context).hasSingleBean(LogRecordExporter.class); @@ -169,8 +169,8 @@ class OtlpLoggingAutoConfigurationTests { @Test void whenHasTransportPropertySetToGrpcUsesGrpcExporter() { this.contextRunner - .withPropertyValues("management.opentelemetry.logging.export.endpoint=http://localhost:4318/v1/logs", - "management.opentelemetry.logging.export.transport=grpc") + .withPropertyValues("management.opentelemetry.logging.export.otlp.endpoint=http://localhost:4318/v1/logs", + "management.opentelemetry.logging.export.otlp.transport=grpc") .run((context) -> { assertThat(context).hasSingleBean(OtlpGrpcLogRecordExporter.class); assertThat(context).hasSingleBean(LogRecordExporter.class); @@ -181,7 +181,7 @@ class OtlpLoggingAutoConfigurationTests { @Test void whenHasMeterProviderBeanAddsItToHttpExporter() { this.contextRunner.withUserConfiguration(MeterProviderConfiguration.class) - .withPropertyValues("management.opentelemetry.logging.export.endpoint=http://localhost:4318/v1/logs") + .withPropertyValues("management.opentelemetry.logging.export.otlp.endpoint=http://localhost:4318/v1/logs") .run((context) -> { OtlpHttpLogRecordExporter otlpHttpLogRecordExporter = context.getBean(OtlpHttpLogRecordExporter.class); assertThat(otlpHttpLogRecordExporter.toBuilder()) @@ -194,8 +194,8 @@ class OtlpLoggingAutoConfigurationTests { @Test void whenHasMeterProviderBeanAddsItToGrpcExporter() { this.contextRunner.withUserConfiguration(MeterProviderConfiguration.class) - .withPropertyValues("management.opentelemetry.logging.export.endpoint=http://localhost:4318/v1/logs", - "management.opentelemetry.logging.export.transport=grpc") + .withPropertyValues("management.opentelemetry.logging.export.otlp.endpoint=http://localhost:4318/v1/logs", + "management.opentelemetry.logging.export.otlp.transport=grpc") .run((context) -> { OtlpGrpcLogRecordExporter otlpGrpcLogRecordExporter = context.getBean(OtlpGrpcLogRecordExporter.class); assertThat(otlpGrpcLogRecordExporter.toBuilder())