Commit 97f9933
committed
fix(vertx-web): finish vertx.route-handler via RoutingContext.addEndHandler fallback
Vert.x's `Http1xServerResponse.end(Buffer, PromiseInternal)` invokes
the registered `endHandler` only when `closed == false` at the moment
the response body has been written. In synthetic transports such as
quarkus-amazon-lambda-rest's `VirtualClientConnection` (in-memory
Netty channel) the writes and the connection close happen
synchronously inside `responseComplete()`, so by the time the
`!closed` guard runs `closed` is already `true` and `endHandler` is
silently skipped.
Symptom: `RouteHandlerWrapper` starts a `vertx.route-handler` span
for every route in the chain (e.g. Quarkus's AuthenticationHandler)
but `EndHandlerWrapper.handle` is never called, so the span is never
finished. The span dies in PendingTrace and is not enqueued on the
writer. All children parented to that span (`jakarta-rs.request`,
`netty.client.request`, downstream `aws.http`/`aws.apigateway`
inferred spans) end up orphaned in the trace UI.
Fix: also register a finish via `RoutingContext.addEndHandler`, which
fires on routing-context completion regardless of underlying
connection state and on both success and failure. Both paths funnel
through a shared idempotent `finishHandlerSpan` so the second one to
fire on real-network transports is a no-op.
Verified end-to-end against a Quarkus 3.15.4 / Java 21 Lambda chain
(caller -> netty.client.request -> callee) on Datadog Lambda
Extension v96. Pre-fix: 5/5 invocations Started, 0/5 Finished.
Post-fix: 5/5 Started, 5/5 Finished, single connected trace tree
in the UI.
Refs: SLES-28371 parent d73cdc9 commit 97f9933
2 files changed
Lines changed: 24 additions & 9 deletions
File tree
- dd-java-agent/instrumentation/vertx/vertx-web/vertx-web-4.0/src/main/java/datadog/trace/instrumentation/vertx_4_0/server
Lines changed: 1 addition & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | 3 | | |
8 | 4 | | |
9 | 5 | | |
| |||
18 | 14 | | |
19 | 15 | | |
20 | 16 | | |
21 | | - | |
22 | 17 | | |
23 | 18 | | |
24 | 19 | | |
25 | 20 | | |
26 | 21 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 22 | + | |
31 | 23 | | |
32 | 24 | | |
33 | 25 | | |
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
47 | 57 | | |
48 | 58 | | |
49 | 59 | | |
| |||
60 | 70 | | |
61 | 71 | | |
62 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
63 | 86 | | |
64 | 87 | | |
65 | 88 | | |
| |||
0 commit comments