OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.14k stars 587 forks source link

BETA BLOG - Providing logs to OpenTelemetry using MicroProfile Telemetry 2.0 #29332

Open pgunapal opened 1 month ago

pgunapal commented 1 month ago

The information you provide here will be included in the Open Liberty beta blog post (example), which will be published on openliberty.io/blog/, and potentially elsewhere, to promote this beta feature/function of Open Liberty. For this post to be included in the beta issue please make sure that this is completed by the end of Friday following the GM (Tuesday). The beta and release blogs are created using automation and rely on you following the template's structure. DO NOT REMOVE/ALTER THE <GHA> TAGS THROUGHOUT THIS TEMPLATE.

<GHA-BLOG-SUMMARY>

MicroProfile Telemetry 2.0 provides developers with the latest Open Telemetry technology; In addition to distributed tracing, the feature now allows OpenTelemetry to collect and export metrics and logs.

Logs Open Liberty runtime log sources (messages, traces, ffdcs) and application logs generated via java.util.logging (JUL) can now be collected with OpenTelemetry with the MpTelemetry 2.0 feature.

To enable the MicroProfile Telemetry 2.0 feature to collect all logs, add the following configuration to your server.xml:

<features>
   <feature>mpTelemetry-2.0</feature>
</features>

<mpTelemetry source="message, trace, ffdc"/>

By default, the message source will be set, if the <mpTelemetry/>' server configuration element or thesourceattribute is not configured in the server.xml, which means only messages will be collected. If thesource=""`, then no logs will be bridged over to OpenTelemetry.

To collect and export runtime-level logs, enable OpenTelemetry using system properties or environment variables:

otel.sdk.disabled=false / OTEL_SDK_DISABLED=false

If you would like to separately configure multiple applications in a server, you can configure OpenTelemetry with application configuration. Note that you will not collect runtime-level logs this way.

By default, all OpenTelemetry data is exported to OTLP. You can change each exporter with the following properties:

otel.logs.exporter/OTEL_LOGS_EXPORTER

What happens next?

pgunapal commented 1 month ago

Epic #27711

pgunapal commented 1 month ago

Parent Beta blog already released for 24008-beta: https://openliberty.io/blog/2024/07/30/24.0.0.8-beta.html#mptel