Prepare your development environment for MicroProfile Telemetry
Before you manually instrument your code to use MicroProfile Telemetry to collect metrics and traces, you must enable MicroProfile Telemetry in your development environment by editing your runtime configuration. You must also add the OpenTelemetry API and annotations as a dependency on your build path.
Before you manually instrument your code to collect traces or define custom metrics, complete the following prerequisites.
Enable MicroProfile Telemetry, as described in Enabling MicroProfile Telemetry for Open Liberty.
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>
Add the
opentelemetry
API and OpenTelemetry instrumentation annotations as a provided dependency to your build path. For example, with Maven, add the following code to yourpom.xml
file.<dependency> <groupId>io.opentelemetry</groupId> <artifactId>opentelemetry-api</artifactId> <version>1.39.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>io.opentelemetry.instrumentation</groupId> <artifactId>opentelemetry-instrumentation-annotations</artifactId> <version>1.39.0-alpha</version> <scope>provided</scope> </dependency>
After you complete those prerequisites, you’re ready to instrument your code.