Skip to content

Fix Netty 4.1 server span completion for streaming responses#11941

Draft
ygree wants to merge 2 commits into
ygree/fix-netty41-http11-pipelining-context-queuefrom
ygree/fix-netty41-chunked-tracing
Draft

Fix Netty 4.1 server span completion for streaming responses#11941
ygree wants to merge 2 commits into
ygree/fix-netty41-http11-pipelining-context-queuefrom
ygree/fix-netty41-chunked-tracing

Conversation

@ygree

@ygree ygree commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Updates Netty 4.1 server instrumentation to keep request spans open until the HTTP response is actually complete.

It tracks pending HTTP/1.1 request contexts in FIFO order, finishes streaming/chunked responses on LastHttpContent, finishes header-complete responses such as 204/205/304, HEAD, CONNECT, Content-Length: 0, and WebSocket upgrades at the response headers, and marks incomplete responses as errors when the channel closes.

Motivation

Netty 4.1 server spans could finish when the first response headers/chunk were written instead of when the response completed. That made streaming response durations too short and could misattribute spans on keep-alive or pipelined HTTP/1.1 connections.

Additional Notes

The fix avoids relying on a single channel-level streaming context because that is not sufficient for pipelined requests. Response writes are matched to the queued request context instead.

Contributor Checklist

Jira ticket: APMS-20050

@ygree ygree self-assigned this Jul 14, 2026
@ygree ygree added type: bug fix Bug fix inst: netty Netty instrumentation tag: ai generated Largely based on code generated by an AI or LLM labels Jul 14, 2026
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 69.73% (+0.00%)

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

@dd-octo-sts

dd-octo-sts Bot commented Jul 14, 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.00 s 13.93 s [-0.3%; +1.3%] (no difference)
startup:insecure-bank:tracing:Agent 12.96 s 13.05 s [-1.4%; +0.1%] (no difference)
startup:petclinic:appsec:Agent 16.84 s 16.65 s [+0.2%; +2.1%] (maybe worse)
startup:petclinic:iast:Agent 16.91 s 16.92 s [-1.2%; +1.0%] (no difference)
startup:petclinic:profiling:Agent 16.46 s 16.30 s [-3.7%; +5.6%] (no difference)
startup:petclinic:sca:Agent 16.81 s 16.63 s [+0.0%; +2.2%] (maybe worse)
startup:petclinic:tracing:Agent 15.73 s 15.72 s [-5.8%; +5.9%] (unstable)

Commit: f65d4a45 · 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.

@ygree ygree force-pushed the ygree/fix-netty41-chunked-tracing branch from 5e8efd4 to 8a32be2 Compare July 14, 2026 05:39
Keep server spans open until terminal response writes, finish incomplete
responses on channel close, and use queued request contexts to avoid
keep-alive/pipelining misattribution. Cover chunked, bodyless, HEAD,
CONNECT, interim, and WebSocket upgrade response cases.
@ygree ygree force-pushed the ygree/fix-netty41-chunked-tracing branch from 8a32be2 to f65d4a4 Compare July 14, 2026 06:10
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.

1 participant