Commit 3bca1f0
fix(aws-lambda): force placeholder resource so the Lambda Extension drops dd-tracer-serverless-span (#11313)
fix(aws-lambda): force placeholder resource so the Lambda Extension drops dd-tracer-serverless-span
The Datadog Lambda Extension filters the placeholder invocation span
by comparing `span.resource == "dd-tracer-serverless-span"` (see
`bottlecap/src/traces/trace_processor.rs::filter_span_from_lambda_library_or_runtime`).
The intent is that the extension drops the placeholder so the
inferred `aws.lambda` span (which the end-invocation handshake gives
the same `span_id`) is the surviving record under that key in the
trace store and remains parented to the inferred apigateway root.
In practice the HTTP/JAX-RS instrumentation overwrites the
placeholder's resource with the request route (e.g. "POST /") at
`HTTP_FRAMEWORK_ROUTE` priority during the invocation, so the
extension's filter no longer matches at end-of-invocation. Both
records (the placeholder with `parent_id=0`, and the inferred
`aws.lambda` with `parent_id=apigateway.span_id`) reach the backend
under the same `(trace_id, span_id)` key. The trace store keeps the
placeholder, and the rest of the trace is detached from the inferred
apigateway root.
Fix: in `LambdaHandlerInstrumentation.exit`, force the resource name
back to the literal placeholder marker right before `span.finish()`,
using `ResourceNamePriorities.MANUAL_INSTRUMENTATION` so the override
beats whatever HTTP-framework priority the in-flight instrumentation
has written. Verified end-to-end on Quarkus 3.15.4 / Java 21 / Lambda
Extension v96: pre-fix the placeholder leaks to the backend with
`parent_id=0` and the trace store reports orphans; post-fix zero
`dd_tracer_serverless_span` rows reach the backend and the trace
store reports a single 11-span chunk with no orphans.
Refs: SLES-2837
use tag interceptor priority to avoid clobbering user-set resource names
Add unit test
comment
Co-authored-by: rithikanarayan <rithika.narayan@datadoghq.com>
Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>1 parent 19fa98a commit 3bca1f0
3 files changed
Lines changed: 64 additions & 0 deletions
File tree
- dd-java-agent/instrumentation/aws-java/aws-java-lambda-handler-1.2/src
- main/java/datadog/trace/instrumentation/aws/v1/lambda
- test/groovy
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
129 | 145 | | |
130 | 146 | | |
131 | 147 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
101 | 123 | | |
102 | 124 | | |
103 | 125 | | |
| |||
0 commit comments