mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-30 06:09:14 +00:00
Make OTLP logging connection details back off
Previously, the connection details would only back off if another PropertiesOtlpLoggingConnectionDetails was defined. This commit corrects this so that they will back of if any OtlpLoggingConnectionDetails implementation is defined as a bean. Closes gh-48536
This commit is contained in:
+1
-1
@@ -46,7 +46,7 @@ final class OtlpLoggingConfigurations {
|
||||
static class ConnectionDetails {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnMissingBean(OtlpLoggingConnectionDetails.class)
|
||||
@ConditionalOnProperty("management.opentelemetry.logging.export.otlp.endpoint")
|
||||
PropertiesOtlpLoggingConnectionDetails openTelemetryLoggingConnectionDetails(OtlpLoggingProperties properties) {
|
||||
return new PropertiesOtlpLoggingConnectionDetails(properties);
|
||||
|
||||
+17
@@ -43,6 +43,8 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link OtlpLoggingAutoConfiguration}.
|
||||
@@ -89,6 +91,21 @@ class OtlpLoggingAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void customConnectionDetailsReplacePropertyBasedConnectionDetails() {
|
||||
OtlpLoggingConnectionDetails details = mock(OtlpLoggingConnectionDetails.class);
|
||||
given(details.getUrl(Transport.HTTP)).willReturn("http://localhost:4318/v1/logs");
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.opentelemetry.logging.export.otlp.endpoint=http://localhost:4319/v1/logs")
|
||||
.withBean("customOtlpLoggingConnectionDetails", OtlpLoggingConnectionDetails.class, () -> details)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(OtlpLoggingConnectionDetails.class);
|
||||
assertThat(context).hasBean("customOtlpLoggingConnectionDetails");
|
||||
assertThat(context.getBean(OtlpLoggingConnectionDetails.class).getUrl(Transport.HTTP))
|
||||
.isEqualTo("http://localhost:4318/v1/logs");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenHasNoEndpointPropertyDoesNotProvideBeans() {
|
||||
this.contextRunner.run((context) -> {
|
||||
|
||||
Reference in New Issue
Block a user