Skip to content

fix(aws-lambda): force placeholder resource so the Lambda Extension drops dd-tracer-serverless-span#11313

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
zarir/sles-2837-lambda-placeholder-resource
May 12, 2026
Merged

fix(aws-lambda): force placeholder resource so the Lambda Extension drops dd-tracer-serverless-span#11313
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
zarir/sles-2837-lambda-placeholder-resource

Conversation

@zarirhamza
Copy link
Copy Markdown
Contributor

@zarirhamza zarirhamza commented May 7, 2026

Summary

The Datadog Lambda Extension drops the placeholder invocation span by comparing span.resource == "dd-tracer-serverless-span" (bottlecap/src/traces/trace_processor.rs::filter_span_from_lambda_library_or_runtime). The dedup is what lets the inferred aws.lambda span (which the end-invocation handshake gives the same span_id) be the surviving record under that key in the trace store, parented to the inferred apigateway root.

In practice the HTTP/JAX-RS instrumentation overwrites the placeholder's resource with the request route ("POST /") at HTTP_FRAMEWORK_ROUTE priority during the invocation, so by end-of-invocation the extension's filter no longer matches. 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's parent_id=0, detaching the rest of the trace from the inferred apigateway root.

Fix

In LambdaHandlerInstrumentation.exit, force the resource name back to INVOCATION_SPAN_NAME ("dd-tracer-serverless-span") right before span.finish(), using ResourceNamePriorities.MANUAL_INSTRUMENTATION (6) so the override beats whatever priority the in-flight HTTP/JAX-RS instrumentation has written (HTTP_FRAMEWORK_ROUTE is 3).

Files touched:

  • LambdaHandlerInstrumentation.java (+16/-0): import ResourceNamePriorities, set the resource name in the exit advice.

Test plan

  • Existing aws-java-lambda-handler-1.2 tests still pass.
  • Extend LambdaHandlerInstrumentationTest with a case that simulates HTTP-framework instrumentation overwriting resource and asserts the final serialized span has resource "dd-tracer-serverless-span".
  • 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 (/api/v1/trace/<id> shows orphans, operation_name:dd_tracer_serverless_span rows present in the spans index). Post-fix the spans index returns 0 placeholder rows and the trace store reports a single 11-span chunk with no orphans.

Refs

SLES-2837

Notes

…rops 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
@zarirhamza zarirhamza requested a review from a team as a code owner May 7, 2026 20:04
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Add at least one type, and one component or instrumentation label to the pull request

If you need help, please check our contributing guidelines.

@zarirhamza zarirhamza marked this pull request as draft May 7, 2026 20:06
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf170244a2

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@rithikanarayan rithikanarayan marked this pull request as ready for review May 11, 2026 21:04
@rithikanarayan rithikanarayan added inst: aws lambda AWS Lambda instrumentation type: enhancement Enhancements and improvements labels May 11, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f07b5b0aac

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@rithikanarayan rithikanarayan added this pull request to the merge queue May 12, 2026
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 12, 2026

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented May 12, 2026

View all feedbacks in Devflow UI.

2026-05-12 19:20:56 UTC ℹ️ Start processing command /merge


2026-05-12 19:21:01 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-05-12 20:33:45 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 12, 2026
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 3bca1f0 into master May 12, 2026
586 of 588 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the zarir/sles-2837-lambda-placeholder-resource branch May 12, 2026 20:33
@github-actions github-actions Bot added this to the 1.63.0 milestone May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: aws lambda AWS Lambda instrumentation type: enhancement Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants