All jobs

Add OpenTelemetry Tracing to a Quarkus App

Yes. An agent adds the quarkus-opentelemetry extension, puts trace and span ids in the logs, exports spans over OTLP to a local collector, and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads the build and the request path before it adds an exporter. In a service shaped like the rest-json-quickstart of quarkusio/quarkus-quickstarts, pom.xml imports io.quarkus.platform:quarkus-bom 3.40.1.1, depends on quarkus-rest-jackson with quarkus-junit and rest-assured for tests, targets Java 17 and configures Surefire 3.5.4 with org.jboss.logmanager.LogManager. There is no application.properties. FruitResource.java serves GET, POST and DELETE /fruits from an in-memory set, LegumeResource.java does the same for legumes, and LoggingFilter.java is a ContainerRequestFilter that logs Request %s %s from IP %s through the JBoss Logger on every call. FruitResourceTest.java and LegumeResourceTest.java are @QuarkusTest classes driving the routes with RestAssured, each with an IT subclass for the native profile.

The same repository holds an opentelemetry-quickstart, and the agent reads it as the reference for this platform version rather than guessing at property names: its pom.xml adds quarkus-opentelemetry plus quarkus-observability-devservices-lgtm in provided scope for dev mode, and its application.properties sets quarkus.application.name, turns on quarkus.otel.metrics.enabled and quarkus.otel.logs.enabled, puts traceId=%X{traceId}, parentId=%X{parentId}, spanId=%X{spanId}, sampled=%X{sampled} into quarkus.log.console.format, and sets %test.quarkus.observability.enabled=false so the Grafana LGTM dev service does not start under tests. Its docker-compose.yml runs otel/opentelemetry-collector on 4317 in front of jaegertracing/all-in-one, with otel-collector-config.yaml forwarding OTLP to Jaeger.

Following that reference, the agent adds quarkus-opentelemetry to pom.xml, unversioned under the BOM, and quarkus-observability-devservices-lgtm as provided. It creates src/main/resources/application.properties with quarkus.application.name=rest-json-quickstart, the console format carrying traceId and spanId, and %test.quarkus.observability.enabled=false, leaving the OTLP endpoint at its default so QUARKUS_OTEL_EXPORTER_OTLP_ENDPOINT can point it at the real collector in each environment. LoggingFilter.java keeps its line but no longer needs to carry the id itself: with the format change, every log line written inside a request already shows the trace id the extension put in the MDC. In FruitResource.java the agent adds one attribute to the current span on POST and DELETE, fruit.name from the request body, through Span.current().setAttribute(...), so a trace of a write names what was written. It copies the compose file and collector config into the service as docker-compose.yml and otel-collector-config.yaml, adjusted to this service's name.

Tests stay green because the test profile disables the dev service and the exporter fails soft when no collector answers. The agent adds TracingTest.java, a @QuarkusTest that sends GET /fruits with a W3C traceparent header and asserts the response is 200, and sends one without the header and asserts the same, so a broken propagator or a missing dependency fails the build rather than a deployment. Before pushing it runs ./mvnw -B clean verify, starts the collector and Jaeger with docker compose up, runs the packaged jar, calls /fruits a few times and pastes the trace JSON fetched from Jaeger's /api/traces?service=rest-json-quickstart into the pull request, together with two log lines showing the ids.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add OpenTelemetry tracing to this Quarkus service and open a pull request. Read pom.xml, src/main/java/org/acme/rest/json/LoggingFilter.java, FruitResource.java, LegumeResource.java, src/test/java/org/acme/rest/json/FruitResourceTest.java and FruitResourceIT.java first, and read the opentelemetry-quickstart directory of quarkusio/quarkus-quickstarts for this platform version's property names before you write any. Add quarkus-opentelemetry to pom.xml unversioned under the BOM and quarkus-observability-devservices-lgtm in provided scope. Create src/main/resources/application.properties with quarkus.application.name set to the artifact id, a console log format that includes traceId and spanId from the MDC, and the observability dev service disabled in the test profile; leave the OTLP endpoint at its default. In FruitResource add a fruit.name span attribute on POST and DELETE through Span.current(). Add docker-compose.yml and otel-collector-config.yaml for a local collector in front of Jaeger. Add TracingTest, a QuarkusTest that sends GET /fruits with and without a traceparent header and asserts 200. Run ./mvnw -B clean verify, start the collector and Jaeger, run the packaged jar, call /fruits, and paste one trace from Jaeger's /api/traces endpoint and two log lines with ids in the pull request. Use explicit imports. Do not change the Dockerfiles or the existing tests.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is a pull request with two new dependencies in pom.xml, a new application.properties, a small change in FruitResource.java, a new TracingTest.java, and docker-compose.yml plus otel-collector-config.yaml for local use. The description shows a trace from Jaeger with a server span for GET /fruits under the rest-json-quickstart service, a POST /fruits span carrying fruit.name, two console lines with matching traceId values, and the Surefire summary from clean verify.

On a repository with a Maven workflow, the pull request builds with ./mvnw clean install on the workflow's JDK and runs the existing FruitResourceTest and LegumeResourceTest unchanged, since the test profile starts no dev service and the exporter is silent without a collector.

A reviewer checks that the OTLP endpoint is left to the environment rather than hard-coded, that quarkus.otel.logs.enabled and metrics are off unless the team wants them exported too, that the span attribute carries no personal data, and that the compose file is for local use only. Then they set QUARKUS_OTEL_EXPORTER_OTLP_ENDPOINT in the deployment that has a collector.

Run it on every Quarkus service onboarded to tracing

A platform team bringing its services onto one collector sends one POST /o/{org}/sessions per repository with this prompt and that repository in resources. Each run reads its own pom.xml, so a service already on quarkus-opentelemetry gets only the log format and span attributes it lacks, and each run opens its own pull request against its own tests.

Give the API key a webhook_url and Rush POSTs run.completed when each turn ends, with the session_url to read the pull request and the pasted trace from.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

Adding a tracer is a configuration change whose proof is a trace, not a diff. In a Rush sandbox the agent runs the collector and Jaeger in containers, runs the packaged jar against them, and fetches a real trace through Jaeger's HTTP API, so the pull request shows a span tree for this service rather than a promise that one will appear. Every mvnw and docker compose command and its output stays in the run's record.

The property names for this platform version come from the quickstart repository's own opentelemetry-quickstart, which the agent reads before writing, so the pull request does not carry settings from an older guide. The same request works unchanged on every Quarkus service a team owns.

Frequently asked questions

Will tests try to reach a collector?

No. The test profile sets %test.quarkus.observability.enabled=false, the same line the reference quickstart uses, so no Grafana LGTM container starts under mvnw verify. Without a collector the OTLP exporter drops spans and logs a warning rather than failing a request.

Does dev mode need Docker?

Only if you want the dev service. quarkus-observability-devservices-lgtm is in provided scope and starts a Grafana LGTM container when ./mvnw quarkus:dev runs with Docker available. Without Docker, dev mode still starts and simply exports nowhere.

What goes into the span attribute?

On POST and DELETE /fruits the current span gets fruit.name from the request body. It is a demo value in this quickstart; in your service the agent picks an identifier that is useful in a trace and not personal data, and the reviewer confirms the choice.

Can it export metrics and logs too?

Yes. The reference quickstart turns on quarkus.otel.metrics.enabled and quarkus.otel.logs.enabled. The agent leaves them at their defaults unless the prompt asks, because each adds volume at the collector that the team should decide on.

More Quarkus jobs

The same job on other stacks

Keep reading