Skip to content

OtelHttpTracing is not using the same trace as Jetty or Undertow #4001

Description

@froque
package com.example;

import static io.jooby.Jooby.runApp;

import io.jooby.opentelemetry.OtelHttpTracing;
import io.jooby.opentelemetry.OtelModule;
import io.opentelemetry.api.GlobalOpenTelemetry;

public class App {

	public static void main(final String[] args) {
		runApp(args, app -> {

			app.install(new OtelModule(GlobalOpenTelemetry.get()));
			app.use(new OtelHttpTracing());

			app.get("/foo", ctx -> "Welcome to Jooby!");
		});
	}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.example</groupId>
	<artifactId>jooby-otel</artifactId>
	<version>1.0-SNAPSHOT</version>

	<properties>
		<maven.compiler.source>25</maven.compiler.source>
		<maven.compiler.target>25</maven.compiler.target>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
			<version>2.0.18</version>
		</dependency>
		<dependency>
			<groupId>io.jooby</groupId>
			<artifactId>jooby</artifactId>
			<version>4.5.4</version>
		</dependency>
		<dependency>
			<groupId>io.jooby</groupId>
			<artifactId>jooby-jetty</artifactId>
			<version>4.5.4</version>
		</dependency>
		<dependency>
			<groupId>io.jooby</groupId>
			<artifactId>jooby-opentelemetry</artifactId>
			<version>4.5.4</version>
		</dependency>
	</dependencies>
</project>

JVM arguments: -javaagent:opentelemetry-javaagent-2.30.0.jar -Dotel.traces.exporter=console

❯ curl http://localhost:8080/foo
Welcome to Jooby!

Logs:

[otel.javaagent 2026-09-09 18:37:51:648 +0100] [worker-78] INFO io.opentelemetry.exporter.logging.LoggingSpanExporter - 'GET /foo' : 798a732cd9ad93cdb6aeb75bac8edec9 1b83eade46b9a771 SERVER [tracer: io.jooby.opentelemetry:] AttributesMap{data={thread.name=worker-78, http.route=/foo, http.response.status_code=200, thread.id=78, http.request.method=GET, url.path=/foo}, capacity=128, totalAddedValues=6}
[otel.javaagent 2026-09-09 18:37:51:653 +0100] [worker-78] INFO io.opentelemetry.exporter.logging.LoggingSpanExporter - 'GET' : 35205a3f2c1dd9ae541361f119b3c100 174229cc585746ba SERVER [tracer: io.opentelemetry.jetty-12.0:2.30.0-alpha] AttributesMap{data={url.scheme=http, thread.name=worker-78, network.protocol.version=1.1, network.peer.port=46822, user_agent.original=curl/7.81.0, http.response.status_code=200, thread.id=78, http.request.method=GET, url.path=/foo, server.port=8080, network.peer.address=127.0.0.1, server.address=localhost, client.address=127.0.0.1}, capacity=128, totalAddedValues=13}

I was expecting the Jooby span to be an inner span of the Jetty trace 35205a3f2c1dd9ae541361f119b3c100 and not a new trace 798a732cd9ad93cdb6aeb75bac8edec9.

This also happens with jooby-undertow. jooby-netty does not log an extra trace.

Jetty instrumentation can be disabled with OTEL_INSTRUMENTATION_JETTY_ENABLED=false, but I still think it would make sense for Jooby to not create a new trace.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions