Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Span in Kotlin `withTimeout` has wrong parent

Open
#9,890 3 comments 1 reaction 1 assignee View on GitHub

@mcculls is already working on this.

Since Nov 19, 2025.

Assessment

This issue has not been assessed yet.

Description

type: bug report
Tracer Version(s)

1.54.0

Java Version(s)

21.0.7

JVM Vendor

Other (please specify in comments)

Bug Report

Hi! I have the following code in a Kotlin Ktor server application, when handling an incoming HTTP request:

post("/foo") {
    span("withTimeoutOutside") {
        delay(100)
        withTimeout(500) {
            span("withTimeoutInside") {
                delay(100)
            }
        }
    }
}

I'd expect the root span (for the HTTP request) to have a child of withTimeoutOutside, which has a child of withTimeoutInside. Instead, what I see is this:

Image

This is possibly related to the fixes put in place for https://github.com/DataDog/dd-trace-java/issues/7215.

Let me know if you need me to provide anything else to help with this.

Thanks in advance!

(Am running on OpenJDK 64-Bit Server VM Temurin-21.0.7+6)

Expected Behavior

I'd expect the root span (for the HTTP request) to have a child of withTimeoutOutside, which has a child of withTimeoutInside.

Reproduction Code

No response

Dominant language
Java
Stars
737
Forks
361
Avg merge
3d 20h
Merged PRs (30d)
173

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DataDog/dd-trace-java

All issues in DataDog/dd-trace-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.