Skip to content

Add durable_function_first_invocation tag to aws.lambda spans#747

Draft
lym953 wants to merge 1 commit intomainfrom
yiming.luo/durable-first-invocation-tag
Draft

Add durable_function_first_invocation tag to aws.lambda spans#747
lym953 wants to merge 1 commit intomainfrom
yiming.luo/durable-first-invocation-tag

Conversation

@lym953
Copy link
Contributor

@lym953 lym953 commented Mar 13, 2026

Summary

  • Adds a durable_execution() decorator in datadog_lambda/durable.py that wraps durable orchestration functions
  • On each invocation, checks not context.state.is_replaying() and sets the durable_function_first_invocation tag ("true" or "false") on the active span
  • Errors during tag setting are caught and logged at debug level to avoid disrupting user functions

Test plan

  • test_sets_first_invocation_true_when_not_replaying — tag is "true" when context is not replaying
  • test_sets_first_invocation_false_when_replaying — tag is "false" when context is replaying
  • test_does_not_set_tag_when_no_active_span — no error when span is None
  • test_does_not_raise_when_context_has_no_state — graceful handling of unexpected context shape
  • test_preserves_function_namefunctools.wraps is applied correctly
  • Run pytest tests/test_durable.py — all 18 tests pass

🤖 Generated with Claude Code

Introduces a durable_execution() decorator that sets the
durable_function_first_invocation tag ("true"/"false") on the active
span based on whether the orchestration context is replaying history.

Co-Authored-By: Claude Sonnet 4.6 <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