Skip to content

Fix Java HTTP async continuation lifecycle - #12498

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
andrea.marziali/diag-fix-java-http-async
Sep 18, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
andrea.marziali/diag-fix-java-http-async

Conversation

@amarziali

Copy link
Copy Markdown
Contributor

What Does This Do

Keeps the Java HTTP client context available across all asynchronous response-body callbacks.

The body subscriber previously used a one-shot continuation. The first callback resolved it, so later callbacks could run without the expected context and the trace could be reported before response processing
completed.

The continuation is now held until a terminal event:

  • onComplete
  • onError
  • subscription cancellation

A shared terminal guard ensures concurrent or repeated terminal signals release it exactly once.

sequenceDiagram
    participant Client as HTTP client
    participant Wrapper as BodySubscriber wrapper
    participant Context as Trace continuation
    participant Delegate as Body subscriber

    Client->>Wrapper: onSubscribe(subscription)
    Wrapper->>Delegate: onSubscribe(wrapped subscription)

    loop Response chunks
        Client->>Wrapper: onNext(chunk)
        Wrapper->>Context: resume()
        Wrapper->>Delegate: onNext(chunk)
        Wrapper->>Context: close resumed scope
    end

    alt Response completes
        Client->>Wrapper: onComplete()
        Wrapper->>Context: resume()
        Wrapper->>Delegate: onComplete()
        Wrapper->>Context: release once
    else Response fails
        Client->>Wrapper: onError(error)
        Wrapper->>Context: resume()
        Wrapper->>Delegate: onError(error)
        Wrapper->>Context: release once
    else Subscription is cancelled
        Delegate->>Wrapper: cancel()
        Wrapper->>Client: delegate cancel()
        Wrapper->>Context: release once
    end
Loading

Motivation

Java HTTP response bodies can invoke onNext multiple times. Their tracing context must remain available until body processing actually terminates, including cancellation.

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@amarziali amarziali added type: bug fix Bug fix inst: java Core Java language instrumentation labels Sep 15, 2026
@amarziali
amarziali requested review from a team as code owners September 15, 2026 10:14
@amarziali amarziali added the tag: ai generated Largely based on code generated by an AI or LLM label Sep 15, 2026
@amarziali
amarziali requested review from jordan-wong and mhdatie and removed request for a team September 15, 2026 10:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-15T11:01:04.951589Z 72169ba Manual request
🔒 Security Review Completed 2026-09-15T10:57:05.564390Z 72169ba Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-prod-us1-6 datadog-prod-us1-6 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog Autotest: FAIL

A custom body subscriber can throw from onSubscribe or onNext. The held continuation then has no release path, so it can keep trace context and stop trace reporting.

Open Bits AI session

🤖 Datadog Autotest · Commit 257fe75 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 257fe750c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Sep 15, 2026

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 59.03% (-0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b3f2a16 | Docs | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.96 s 14.00 s [-1.0%; +0.5%] (no difference)
startup:insecure-bank:tracing:Agent 12.91 s 12.99 s [-1.4%; +0.1%] (no difference)
startup:petclinic:appsec:Agent 17.64 s 17.43 s [+0.5%; +2.0%] (maybe worse)
startup:petclinic:iast:Agent 17.40 s 17.57 s [-1.7%; -0.2%] (maybe better)
startup:petclinic:profiling:Agent 17.45 s 17.28 s [-0.4%; +2.4%] (no difference)
startup:petclinic:sca:Agent 17.61 s 17.60 s [-1.1%; +1.1%] (no difference)
startup:petclinic:tracing:Agent 16.48 s 16.17 s [-2.3%; +6.1%] (no difference)

Commit: b3f2a164 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@amarziali

Copy link
Copy Markdown
Contributor Author

@DataDog review

@datadog-prod-us1-6 datadog-prod-us1-6 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog Autotest: PASS

More details

The held continuation stays available for each response-body callback. Each terminal path releases it one time.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 72169ba · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@amarziali

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 72169baf12

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 72169baf12

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jordan-wong jordan-wong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left one non-blocking comment about potential test coverage

@amarziali
amarziali enabled auto-merge September 18, 2026 08:59
@amarziali
amarziali added this pull request to the merge queue Sep 18, 2026
@dd-octo-sts

dd-octo-sts Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Sep 18, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-09-18 09:46:32 UTC ℹ️ Start processing command /merge


2026-09-18 09:46:37 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-09-18 10:57:26 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 18, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 0854571 into master Sep 18, 2026
604 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the andrea.marziali/diag-fix-java-http-async branch September 18, 2026 10:57
@github-actions github-actions Bot added this to the 1.67.0 milestone Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: java Core Java language instrumentation tag: ai generated Largely based on code generated by an AI or LLM type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants