Skip to content

feat: Add automatic trace propagation for Lambda Durable Functions#752

Closed
jchrostek-dd wants to merge 1 commit intomainfrom
john/df-trace-propagation
Closed

feat: Add automatic trace propagation for Lambda Durable Functions#752
jchrostek-dd wants to merge 1 commit intomainfrom
john/df-trace-propagation

Conversation

@jchrostek-dd
Copy link
Copy Markdown
Contributor

Summary

Adds automatic tracing support for AWS Lambda Durable Functions (preview feature announced at re:Invent 2025).

Key features:

  • Auto-patches @aws/durable-execution-sdk-js when datadog-lambda-js loads
  • Extracts trace context from preserved InputPayload (supports HTTP headers, SNS/SQS attributes, EventBridge)
  • Falls back to deterministic trace ID from execution ARN when no parent exists
  • Creates child spans for each operation (step, wait, invoke, parallel, map)
  • Detects replay operations to avoid duplicate spans

Zero user code changes required - existing code with datadog() wrapper works automatically.

Test plan

  • Unit tests added (55 new tests)
  • All 575 tests pass
  • Integration test with deployed durable function
  • Verify trace appears correctly in Datadog APM

Example trace output

[api-gateway] POST /workflow
    └─[aws.lambda] my-durable-fn (invocation 1)
          │  trace_id: 123456 (from API Gateway)
          ├─[aws.lambda.durable.step] fetch-user
          └─[aws.lambda.durable.wait] delay-5min (Lambda exits PENDING)

    ... 5 minutes later ...

    └─[aws.lambda] my-durable-fn (invocation 2)
          │  trace_id: 123456 (SAME - preserved)
          │  (fetch-user replayed - no duplicate span)
          ├─[aws.lambda.durable.wait] delay-5min (completes)
          └─[aws.lambda.durable.step] process

🤖 Generated with Claude Code

This adds automatic tracing support for AWS Lambda Durable Functions:

- Auto-patches @aws/durable-execution-sdk-js when datadog-lambda-js loads
- Extracts trace context from preserved InputPayload (HTTP headers, SNS/SQS attributes)
- Falls back to deterministic trace ID from execution ARN when no parent exists
- Creates child spans for each operation (step, wait, invoke, parallel, map)
- Detects replay operations to avoid duplicate spans

Zero user code changes required - existing code with datadog() wrapper works automatically.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant