Browse Source

Rename management.opentelemetry.logging.export properties

They are now under 'management.opentelemetry.logging.export.otlp.*'.

Closes gh-47954
pull/47991/head
Moritz Halbritter 1 month ago
parent
commit
7e5897066c
  1. 3
      documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/loggers.adoc
  2. 1
      module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfiguration.java
  3. 8
      module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingConfigurations.java
  4. 2
      module/spring-boot-opentelemetry/src/main/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingProperties.java
  5. 20
      module/spring-boot-opentelemetry/src/main/resources/META-INF/additional-spring-configuration-metadata.json
  6. 10
      module/spring-boot-opentelemetry/src/test/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfigurationIntegrationTests.java
  7. 28
      module/spring-boot-opentelemetry/src/test/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfigurationTests.java

3
documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/loggers.adoc

@ -45,7 +45,8 @@ management: @@ -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.

1
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; @@ -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 {

8
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; @@ -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 { @@ -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 { @@ -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> meterProvider) {
@ -98,7 +100,7 @@ final class OtlpLoggingConfigurations { @@ -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> meterProvider) {
OtlpGrpcLogRecordExporterBuilder builder = OtlpGrpcLogRecordExporter.builder()

2
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; @@ -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 {
/**

20
module/spring-boot-opentelemetry/src/main/resources/META-INF/additional-spring-configuration-metadata.json

@ -7,12 +7,12 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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"
}
}

10
module/spring-boot-opentelemetry/src/test/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfigurationIntegrationTests.java

@ -48,7 +48,7 @@ class OtlpLoggingAutoConfigurationIntegrationTests { @@ -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 { @@ -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 { @@ -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);

28
module/spring-boot-opentelemetry/src/test/java/org/springframework/boot/opentelemetry/autoconfigure/logging/OtlpLoggingAutoConfigurationTests.java

@ -77,7 +77,7 @@ class OtlpLoggingAutoConfigurationTests { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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())

Loading…
Cancel
Save