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.
docker run --pull always \
-p 127.0.0.1:8000:8000 \
ghcr.io/buggregator/server:latest2. Download the agent
curl -L -O https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar3. 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.
OTEL_SERVICE_NAME=checkout
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:8000
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_METRICS_EXPORTER=noneThe protocol must be http/protobuf or http/json. Buggregator does not accept OTLP over gRPC.
4. Run the app with the agent
java -javaagent:./opentelemetry-javaagent.jar -jar target/app.jarStarted from Maven, your IDE or a container? Put the same flag in JAVA_TOOL_OPTIONS instead.
JAVA_TOOL_OPTIONS="-javaagent:./opentelemetry-javaagent.jar" ./mvnw spring-boot:run5. 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.
Docs: docs.buggregator.dev/config/opentelemetry.html#otel-sdk
Requires Buggregator v2.12.0+
Related tips
- Sentry
Spring Boot errors through the Sentry Java SDK, locally
Add the Sentry Spring Boot starter and point sentry.dsn at Buggregator. Exceptions, traces and logs of your app show up on your machine.
- OpenTelemetry
Add Buggregator to your OTel Collector as one more exporter
Add an otlphttp exporter to your Collector config. Traces and logs from every service show up in Buggregator, and the apps stay as they are.
- Sentry
See a Laravel request's Sentry trace as a waterfall
Turn on Sentry tracing in Laravel and send it to Buggregator. Every span of a request shows on a timeline, and errors link to their trace.
- Mail
Spring Boot mail to a local inbox, two properties
Set spring.mail.host and spring.mail.port to Buggregator. Mail sent with JavaMailSender lands in a local inbox with HTML preview. Nothing is delivered.
Checked on with Buggregator v2.13.0