Merge pull request #41825 from famaridon
* pr/41825: Polish "Added documentation for configuring OpenTelemetry SDK logs" Added documentation for configuring OpenTelemetry SDK logs Closes gh-41825
This commit is contained in:
@@ -83,6 +83,7 @@ dependencies {
|
||||
implementation("io.micrometer:micrometer-tracing")
|
||||
implementation("io.micrometer:micrometer-registry-graphite")
|
||||
implementation("io.micrometer:micrometer-registry-jmx")
|
||||
implementation("io.opentelemetry.instrumentation:opentelemetry-logback-appender-1.0")
|
||||
implementation("io.projectreactor.netty:reactor-netty-http")
|
||||
implementation("io.undertow:undertow-core")
|
||||
implementation("jakarta.annotation:jakarta.annotation-api")
|
||||
|
||||
@@ -31,3 +31,28 @@ To configure a given logger, `POST` a partial entity to the resource's URI, as t
|
||||
----
|
||||
|
||||
TIP: To "`reset`" the specific level of the logger (and use the default configuration instead), you can pass a value of `null` as the `configuredLevel`.
|
||||
|
||||
|
||||
|
||||
[[actuator.loggers.opentelemetry]]
|
||||
== OpenTelemetry
|
||||
By default, logging via OpenTelemetry is not configured.
|
||||
You have to provide the location of the OpenTelemetry logs endpoint to configure it:
|
||||
|
||||
[configprops,yaml]
|
||||
----
|
||||
management:
|
||||
otlp:
|
||||
logging:
|
||||
endpoint: "https://otlp.example.com:4318/v1/logs"
|
||||
----
|
||||
|
||||
NOTE: The OpenTelemetry Logback appender and Log4j appender are not part of Spring Boot.
|
||||
For more details, see the https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/logback/logback-appender-1.0/library[OpenTelemetry Logback appender] or the https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/log4j/log4j-appender-2.17/library[OpenTelemetry Log4j2 appender] in the https://github.com/open-telemetry/opentelemetry-java-instrumentation[OpenTelemetry Java instrumentation GitHub repository].
|
||||
|
||||
TIP: You have to configure the appender in your `logback-spring.xml` or `log4j2-spring.xml` configuration to get OpenTelemetry logging working.
|
||||
|
||||
The `OpenTelemetryAppender` for both Logback and Log4j requires access to an `OpenTelemetry` instance to function properly.
|
||||
This instance must be set programmatically during application startup, which can be done like this:
|
||||
|
||||
include-code::OpenTelemetryAppenderInitializer[]
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docs.actuator.loggers.opentelemetry;
|
||||
|
||||
import io.opentelemetry.api.OpenTelemetry;
|
||||
import io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
class OpenTelemetryAppenderInitializer implements InitializingBean {
|
||||
|
||||
private final OpenTelemetry openTelemetry;
|
||||
|
||||
OpenTelemetryAppenderInitializer(OpenTelemetry openTelemetry) {
|
||||
this.openTelemetry = openTelemetry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
OpenTelemetryAppender.install(this.openTelemetry);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -159,6 +159,13 @@ bom {
|
||||
]
|
||||
}
|
||||
}
|
||||
library("OpenTelemetry Logback Appender", "2.7.0-alpha") {
|
||||
group("io.opentelemetry.instrumentation") {
|
||||
modules = [
|
||||
"opentelemetry-logback-appender-1.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
library("Plexus Build API", "0.0.7") {
|
||||
group("org.sonatype.plexus") {
|
||||
modules = [
|
||||
|
||||
Reference in New Issue
Block a user