Skip to content

Goodnotes fix: Netty streaming span lifecycle (v1.60.0)

Latest

Choose a tag to compare

@gtukmachev gtukmachev released this 24 Feb 14:25
14b968a

Goodnotes patch on top of dd-java-agent 1.60.0

Fixes DataDog APM instrumentation for Ktor/Netty streaming endpoints (respondOutputStream):

Problem: HttpServerResponseTracingHandler closes the root span when HTTP headers are written, not when the stream completes. This causes near-zero latency and always-200 status codes in DD APM for streaming responses.

Three fixes in dd-java-agent/instrumentation/netty/netty-4.1:

  1. Correct instanceof check order — FullHttpResponse before HttpResponse before LastHttpContent
  2. Span lifecycle tied to stream end — span finishes on LastHttpContent, not on header write
  3. STREAMING_CONTEXT_KEY — separate channel attribute for streaming spans, immune to keep-alive race condition

Validated with 5-min load test (110 threads, 46k requests, 0 failures):

  • Streaming fast (5×10ms chunks): p50 54ms ✅ (was ~0ms)
  • Streaming slow (5×1s chunks): p50 5002ms ✅ (was ~0ms)

Upstream PR: DataDog#10656

Branch: gsc-577-fix-ktor-streaming-instrumentation