Skip to content

Prevent Netty idle timers from retaining request context - #12503

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
andrea.marziali/diag-fix-vertx-clients
Sep 16, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
andrea.marziali/diag-fix-vertx-clients

Conversation

@amarziali

Copy link
Copy Markdown
Contributor

What Does This Do

Prevents Netty’s channel-owned idle timers from capturing the request context active during channel initialization.

IdleStateHandler.initialize() creates recurring timeout tasks. When initialization happens during the first Vert.x request, those tasks can inherit its context even though their lifecycle belongs to the channel
and continues until channel teardown.

The existing async-propagation suppression instrumentation now disables propagation only while these timers are created, restoring the previous state on normal and exceptional exits.

sequenceDiagram
    participant Request as First client request
    participant Handler as Netty IdleStateHandler
    participant Agent as Context instrumentation
    participant Timer as Channel idle timer
    participant Channel

    Request->>Handler: initialize(channel context)
    Handler->>Agent: enter initialize()
    Agent->>Agent: save propagation state
    Agent->>Agent: disable async propagation
    Handler->>Timer: create recurring timeout task
    Note over Timer: Channel-owned task<br/>No request context captured
    Handler-->>Agent: exit initialize()
    Agent->>Agent: restore propagation state
    Handler-->>Request: continue request
    Timer->>Channel: monitor idle state until teardown
Loading

Motivation

The idle timer belongs to the channel rather than to the request that happens to initialize it. Capturing that request’s context retains its continuation beyond request completion and can delay trace publication.

Suppressing capture at the timer-creation boundary preserves normal propagation for Vert.x callbacks, errors, cancellation and request processing.

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@amarziali amarziali added type: bug fix Bug fix inst: netty Netty instrumentation labels Sep 15, 2026
@amarziali
amarziali requested review from a team as code owners September 15, 2026 10:33
@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 AlexeyKuznetsov-DD and ygree and removed request for a team September 15, 2026 10:33
@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-15T10:35:26.093870Z 5a02f2b PR opened
🔒 Security Review Completed 2026-09-15T10:36:40.555298Z 5a02f2b PR opened
ℹ️ 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-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot 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.

Datadog Autotest: PASS

More details

The new matcher limits propagation suppression to IdleStateHandler.initialize(ChannelHandlerContext). The shared advice restores the prior propagation state on normal and exceptional exits.

Was this helpful? React 👍 or 👎

Open Bits AI session

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

@datadog-datadog-prod-us1-2

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

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 68.82% (+9.78%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 33cc72c | Docs | View more details | 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 14.83 s 14.65 s [+0.4%; +2.0%] (maybe worse)
startup:insecure-bank:tracing:Agent 13.57 s 13.71 s [-1.8%; -0.3%] (maybe better)
startup:petclinic:appsec:Agent 17.55 s 17.39 s [+0.1%; +1.8%] (maybe worse)
startup:petclinic:iast:Agent 17.41 s 17.08 s [-2.4%; +6.3%] (no difference)
startup:petclinic:profiling:Agent 17.38 s 17.21 s [-0.1%; +2.1%] (no difference)
startup:petclinic:sca:Agent 17.52 s 16.84 s [-0.3%; +8.3%] (no difference)
startup:petclinic:tracing:Agent 16.48 s 16.18 s [-2.5%; +6.1%] (no difference)

Commit: 33cc72c4 · 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
amarziali force-pushed the andrea.marziali/diag-fix-vertx-clients branch from 5a02f2b to 33cc72c Compare September 15, 2026 11:22

@ygree ygree 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.

IDM approved. Side note: AsyncPropagatingDisableInstrumentation targets too many different classes. In my opinion, it should have been split into specialised modules in the first place.

@amarziali

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

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

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-09-16 07:54:58 UTC ℹ️ Start processing command /merge


2026-09-16 07:55:04 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-09-16 09:06:27 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 6bf5f5e into master Sep 16, 2026
602 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the andrea.marziali/diag-fix-vertx-clients branch September 16, 2026 09:06
@github-actions github-actions Bot added this to the 1.67.0 milestone Sep 16, 2026
jandro996 pushed a commit that referenced this pull request Sep 17, 2026
Prevent Netty idle timers from retaining request context

Co-authored-by: andrea.marziali <andrea.marziali@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: netty Netty 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.

2 participants