Skip to main content

Spring Boot traces from the OpenTelemetry Java agent

Start your Spring Boot app with the OpenTelemetry Java agent and set OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:8000 and OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf. Each request then shows up in Buggregator as a trace, with its spans on a timeline. You change no code. Turn the metrics exporter off, because Buggregator takes traces and logs only.

Steps

1. Start Buggregator

OpenTelemetry needs Buggregator 2.12.0 or newer. It takes OTLP over HTTP on the main port 8000.

bash
docker run --pull always \
  -p 127.0.0.1:8000:8000 \
  ghcr.io/buggregator/server:latest

2. Download the agent

bash
curl -L -O https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar

3. Point the agent at Buggregator

Set these in the app's environment. The service name is what the UI shows in the Service column. In Docker Compose, use the Buggregator service name instead of 127.0.0.1.

dotenv
OTEL_SERVICE_NAME=checkout
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:8000
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_METRICS_EXPORTER=none

The protocol must be http/protobuf or http/json. Buggregator does not accept OTLP over gRPC.

4. Run the app with the agent

bash
java -javaagent:./opentelemetry-javaagent.jar -jar target/app.jar

Started from Maven, your IDE or a container? Put the same flag in JAVA_TOOL_OPTIONS instead.

bash
JAVA_TOOL_OPTIONS="-javaagent:./opentelemetry-javaagent.jar" ./mvnw spring-boot:run

5. Open the trace

Call an endpoint, then open the Sentry page at http://127.0.0.1:8000 and pick Traces. The trace is marked OTel and lists the services it went through. Open it to see its spans as a waterfall. Since agent 2.0 the OTLP logs exporter is on by default, so the log records it captures land on the Logs tab and link to their trace.

Why it works

The agent instruments the libraries your app uses when the JVM starts and sends spans over OTLP. Buggregator answers the standard paths /v1/traces and /v1/logs on port 8000 and shows the data next to your Sentry errors. A failed span is marked as an error.

Checked on with Buggregator v2.13.0

Setup in 60 seconds

No registration. No account. Start it and point your app at it.

1

Start Buggregator

One file, installed with one command. The web UI opens on port 8000. Prefer containers? Use the Docker tab.

$ curl -fsSL https://raw.githubusercontent.com/buggregator/server/master/scripts/install.sh | sh
$ HTTP_ADDR=127.0.0.1:8000 \
  SMTP_ADDR=127.0.0.1:1025 \
  VAR_DUMPER_ADDR=127.0.0.1:9912 \
  MONOLOG_ADDR=127.0.0.1:9913 \
  PROXY_ADDR=127.0.0.1:8080 \
  ~/.local/bin/buggregator

The script picks the file for your CPU: Intel/AMD or ARM.

One file for Linux, macOS and Windows, about 40 MB. Nothing else to install.

This run line keeps it on this computer. Without the *_ADDR settings it listens on all network interfaces

Rather not run a script? Download the file yourself

Runs on Windows, macOS and Linux, on Intel/AMD and ARM.

Prefer not to do it yourself? Your AI agent can set Buggregator up for you