-
Notifications
You must be signed in to change notification settings - Fork 873
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize appenders in the spring boot starter (#8888)
Co-authored-by: Lauri Tulmin <[email protected]>
- Loading branch information
Showing
27 changed files
with
233 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
.../instrumentation/spring/autoconfigure/logging/OpenTelemetryAppenderAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.spring.autoconfigure.logging; | ||
|
||
import io.opentelemetry.api.OpenTelemetry; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.event.ApplicationReadyEvent; | ||
import org.springframework.context.ApplicationListener; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@SuppressWarnings("OtelPrivateConstructorForUtilityClass") | ||
@ConditionalOnBean(OpenTelemetry.class) | ||
public class OpenTelemetryAppenderAutoConfiguration { | ||
|
||
@Configuration | ||
@ConditionalOnProperty( | ||
prefix = "otel.springboot.log4j-appender", | ||
name = "enabled", | ||
matchIfMissing = true) | ||
@ConditionalOnClass({ | ||
io.opentelemetry.instrumentation.log4j.appender.v2_17.OpenTelemetryAppender.class | ||
}) | ||
static class Log4jAppenderConfig { | ||
|
||
@Bean | ||
ApplicationListener<ApplicationReadyEvent> log4jOtelAppenderInitializer( | ||
OpenTelemetry openTelemetry) { | ||
return event -> { | ||
io.opentelemetry.instrumentation.log4j.appender.v2_17.OpenTelemetryAppender.install( | ||
openTelemetry); | ||
}; | ||
} | ||
} | ||
|
||
@Configuration | ||
@ConditionalOnProperty( | ||
prefix = "otel.springboot.logback-appender", | ||
name = "enabled", | ||
matchIfMissing = true) | ||
@ConditionalOnClass({ | ||
io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender.class | ||
}) | ||
static class LogbackAppenderConfig { | ||
|
||
@Bean | ||
ApplicationListener<ApplicationReadyEvent> logbackOtelAppenderInitializer( | ||
OpenTelemetry openTelemetry) { | ||
return event -> { | ||
io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender.install( | ||
openTelemetry); | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.