Monitor Java Spring Boot app with OpenTelemetry

In this tutorial we will be instrumenting Spring boot RealWorld example appopen in new window using OpenTelemetry Java Agent.

OpenTelemetry Spring Boot


RealWorld example appopen in new window is a fullstack app called "Conduit" that consists of a backend (JSON API) and a frontend (UI). There are numerous implementations for different languages and frameworks, but in this turorial we will be using the Spring backend and the React frontend.

OpenTelemetry Java agentopen in new window dynamically injects bytecode into any Java 8+ application to capture telemetry from a number of popular libraries and frameworks. The instrumentation process is completely automatic and does not require any source code modifications.


Uptrace is an open source APMopen in new window and blazingly fast distributed tracing tool powered by OpenTelemetry and ClickHouse. It is a popular alternative to Jaeger and can be installedopen in new window by downloading a pre-compiled binary.

RealWorld backend

Let's start by downloading the backend source code:

git clone

Then we need to build a JAR from the downloaded source code:

cd spring-boot-realworld-example-app
./gradlew bootJar

If you are getting Could not find snakeyaml-1.27-android.jar (org.yaml:snakeyaml:1.27), apply the following diff to build.gradle and try again:

diff --git a/build.gradle b/build.gradle
index 12781f0..52a8f71 100644
--- a/build.gradle
+++ b/build.gradle
@@ -33,6 +33,7 @@ dependencies {
     implementation 'io.jsonwebtoken:jjwt:0.9.1'
     implementation 'joda-time:joda-time:2.10.6'
     implementation 'org.xerial:sqlite-jdbc:3.34.0'
+    implementation 'org.yaml:snakeyaml:1.28'

Now we can start the app using the compiled JAR:

java -jar build/libs/spring-boot-realworld-example-app-0.0.1-SNAPSHOT.jar

You can check that the backend is working by visiting http://localhost:8080/tags:

curl http://localhost:8080/tags

Let's stop the app for now by pressing CTRL+C.

OpenTelemetry agent

It is time to setup OpenTelemetry agent. Let's download the latest pre-compiled JAR:


The agent accepts various configurationopen in new window options either via system properties or environment variables. In the following example we are using environment variables to configure OTLPopen in new window exporter to send data to Uptrace.

export OTEL_EXPORTER_OTLP_HEADERS=uptrace-dsn=https://<token><project_id>

Let's start the backend app again, but this time we will be using Java agent to auto-instrument the JAR:

java -javaagent:opentelemetry-javaagent-all.jar -jar build/libs/spring-boot-realworld-example-app-0.0.1-SNAPSHOT.jar

As usually you can open http://localhost:8080/tags to check that API is working.

RealWorld frontend

We have a working backend, but it is not very interesting without a frontend. Let's go ahead and install a React + Reduxopen in new window frontend that will serve as a UI:

git clone

The app comes with various JS dependencies:

cd react-redux-realworld-example-app
npm install

Now we need to configure the frontend app to use our backend that is running at http://localhost:8080/. You can do that by editing src/agent.js file:

const API_ROOT = 'http://localhost:8080'

After which we can start the React app and enjoy the UI at http://localhost:4100/register:

npm start

After clicking a few links you should see traces like this arriving in your Uptrace project:



By using OpenTelemetry agent we were able to istrument a Java application without changing a single line of code. Curious to try instrumenting your app? Create an Uptrace projectopen in new window and follow this tutorial. Good luck.

Last Updated:
Uptrace is an open-source APM and DataDog alternative that supports OpenTelemetry traces, metrics, and logs. You can use it to monitor apps and set up alerts to receive notifications via email, Slack, Telegram, and more. View on GitHub →Uptrace Demo