MicroProfile Telemetry2.01.11.0
This feature provides support for the Eclipse MicroProfile Telemetry specification for enterprise Java.
MicroProfile Telemetry 2.0 is compatible with multiple versions of the MicroProfile umbrella feature. It is automatically enabled when you enable microprofile-6.1
or microprofile-7.0
. However, it also works with microprofile-5.0
, microprofile-4.1
, or microprofile-1.4
if you separately enable it alongside any of those features.
Enabling this feature
To enable the MicroProfile Telemetry 2.0 feature, add the following element declaration into your server.xml
file, inside the featureManager
element:
<feature>mpTelemetry-2.0</feature>
Examples
Enable OpenTelemetry
To enable OpenTelemetry for Open Liberty, in addition to enabling the MicroProfile Telemetry feature, you must also set the otel.sdk.disabled=false
system property in one of the valid configuration sources. Depending on your application scenario, you can set this property at the runtime level or the application level. For more information, see Collecting and exporting logs, metrics, and traces with OpenTelemetry.
The following example demonstrates how to enable OpenTelemetry at the runtime level by setting the property in your bootstrap.properties
file:
otel.sdk.disabled=false
When you enable the MicroProfile Telemetry feature and set this property, your system is ready to collect and export logs, metrics, and traces. By default, all OpenTelemetry data is exported by using the OpenTelemetry Protocol (OTLP) at the http://localhost:4317
endpoint. You can configure alternative exporter settings by specifying system properties or environment variables. For more information, see OpenTelemetry settings and configuration.
Collect logs from a specified source
To enable the MicroProfile Telemetry feature to collect logs from different sources in the Open Liberty runtime environment, configure the source
attribute for the mpTelemetry
element with a comma-separated list of log sources.
<mpTelemetry source="message, trace, ffdc"/>
The
mpTelemetry
configuration element is optional. If you do not specify it or thesource
attribute, the default configuration source ismessage
.If the source attribute is empty (
source=“”
), no sources are collected, and nothing is routed to the configured OpenTelemetry logs exporter.The attributes and values are case insensitive.
Customize your application telemetry with the OpenTelemetry API
Although OpenTelemetry automatically collects a default set of logs, metrics, and traces, if you need to manually instrument your code to collect traces or define custom metrics, you must make the OpenTelemetry API visible in your development environment.
Enable third-party APIs for your application by adding the following code in your server.xml
file:
<webApplication id="app-name" location="app-name.war">
<classloader apiTypeVisibility="+third-party"/>
</webApplication>
Use MicroProfile Telemetry 2.0 with Java SE 8
Unlike previous versions of MicroProfile Telemetry, version 2.0 supports Java SE 8 in certain configurations.
MicroProfile Telemetry 2.0 (mpTelemetry-2.0
) is included in the MicroProfile 7.0 umbrella feature and platform, which do not support Java SE 8. However, MicroProfile Telemetry 2.0 is compatible with the following earlier versions of MicroProfile that do support Java SE 8:
Although mpTelemetry-2.0
is not automatically enabled by these umbrella features, if you independently enable it alongside any of them, the configuration supports Java SE 8.
For example, the following featureManager
configuration in your server.xml
file enables mpTelemetry-2.0
in a Java SE 8 environment:
<featureManager>
<feature>microProfile-5.0</feature>
<feature>mpTelemetry-2.0</feature>
...
</featureManager>
Alternatively, if you are using versionless features, you must likewise independently enable the versioned mpTelemetry-2.0
feature, along with your chosen platform feature, if you want to use it with Java SE 8. The following example shows the microProfile-5.0
platform feature and several example versionless features enabled together with mpTelemetry-2.0
:
<featureManager>
<platform>microProfile-5.0</platform>
<feature>mpTelemetry-2.0</feature>
<feature>mpHealth</feature>
<feature>mpMetrics</feature>
...
</featureManager>
In this example, the versionless mpHealth
and mpMetrics
features are automatically resolved to compatible versions by the microProfile-5.0
platform. The versioned mpTelemetry-2.0
feature gets the benefit of Java SE 8 support that the platform provides.
Third-party API packages provided by this feature
io.opentelemetry.api
io.opentelemetry.api.baggage
io.opentelemetry.api.baggage.propagation
io.opentelemetry.api.common
io.opentelemetry.api.logs
io.opentelemetry.api.metrics
io.opentelemetry.api.trace
io.opentelemetry.api.trace.propagation
io.opentelemetry.context
io.opentelemetry.context.propagation
io.opentelemetry.exporter.logging
io.opentelemetry.exporter.otlp
io.opentelemetry.exporter.otlp.logs
io.opentelemetry.extension.incubator.metrics
io.opentelemetry.instrumentation.annotations
io.opentelemetry.sdk.autoconfigure.spi
io.opentelemetry.sdk.autoconfigure.spi.logs
io.opentelemetry.sdk.autoconfigure.spi.metrics
io.opentelemetry.sdk.autoconfigure.spi.traces
io.opentelemetry.sdk.common
io.opentelemetry.sdk.logs.data
io.opentelemetry.sdk.logs.export
io.opentelemetry.sdk.metrics
io.opentelemetry.sdk.metrics.data
io.opentelemetry.sdk.metrics.export
io.opentelemetry.sdk.resources
io.opentelemetry.sdk.trace
io.opentelemetry.sdk.trace.data
io.opentelemetry.sdk.trace.export
io.opentelemetry.sdk.trace.samplers
io.opentelemetry.semconv
Developing a feature that depends on this feature
If you are developing a feature that depends on this feature, include the following item in the Subsystem-Content
header in your feature manifest file.
io.openliberty.mpTelemetry-2.0; type="osgi.subsystem.feature"