Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide auto-configurations for OpenTelemetry Logs #40961

Closed
wants to merge 1 commit into from

Conversation

making
Copy link
Member

@making making commented May 31, 2024

This pull request introduces auto-configuration for SdkLoggerProvider and OtlpHttpLogRecordExporter (closes #37355). The implementation basically follows the approach used for Tracing, excluding gRPC.
Instrumentation settings via logback or log4j are out of the scope of this PR because the library is still in alpha version.

There was a consideration to place the package under the existing org.springframework.boot.actuate.autoconfigure.opentelemetry or org.springframework.boot.actuate.autoconfigure.logging. However, a new package org.springframework.boot.actuate.autoconfigure.logs has been created for this auto-configuration. This may need to be changed.

With this auto-configuration, users can configure the Logback Appender to send logs via OLTP as follows:

<!-- logback-spring.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <statusListener class="ch.qos.logback.core.status.NopStatusListener"/>
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
    <include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
    <appender name="OPEN_TELEMETRY"
              class="io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender">
        <captureExperimentalAttributes>true</captureExperimentalAttributes>
        <captureKeyValuePairAttributes>true</captureKeyValuePairAttributes>
    </appender>
    <root level="INFO">
        <appender-ref ref="OPEN_TELEMETRY"/>
        <appender-ref ref="CONSOLE"/>
    </root>
</configuration>
@Bean
public ApplicationListener<ApplicationReadyEvent> logbackOtelAppenderInitializer(OpenTelemetry openTelemetry) {
    return event -> OpenTelemetryAppender.install(openTelemetry);
}
management.otlp.logs.endpoint=http://localhost:4318/v1/logs
management.otlp.logs.headers.authorization=Bearer changeme
management.otlp.logs.compression=gzip
management.otlp.logs.timeout=10s

Additionally, to ensure the functionality of this pull request, an experimental project was created and tested, which also includes auto-configuration for the Logback Appender:
https://github.com/making/otel-logs-autoconfigure

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 31, 2024
@scottfrederick scottfrederick added type: enhancement A general enhancement theme: observability Issues related to observability and removed status: waiting-for-triage An issue we've not yet triaged labels May 31, 2024
@scottfrederick scottfrederick added this to the 3.4.x milestone May 31, 2024
@philwebb philwebb modified the milestones: 3.4.x, 3.5.x Jun 17, 2024
@mhalbritter mhalbritter self-assigned this Jun 27, 2024
@mhalbritter
Copy link
Contributor

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: observability Issues related to observability type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide auto-configuration for OpenTelemetry logs
5 participants