Skip to content

refactor(durable): [SVLS-9168] Extract operation span names as constants#18384

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 11 commits into
mainfrom
yiming.luo/durable-span-name-const
Jun 5, 2026
Merged

refactor(durable): [SVLS-9168] Extract operation span names as constants#18384
gh-worker-dd-mergequeue-cf854d[bot] merged 11 commits into
mainfrom
yiming.luo/durable-span-name-const

Conversation

@lym953

@lym953 lym953 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Extracts all "aws.durable.*" span name string literals from patch.py into named constants in ddtrace/ext/aws_durable.py, then replaces every bare literal with the corresponding constant.

New constants added to ddtrace/ext/aws_durable.py:

  • SPAN_STEP
  • SPAN_WAIT
  • SPAN_WAIT_FOR_CONDITION
  • SPAN_WAIT_FOR_CALLBACK
  • SPAN_CREATE_CALLBACK
  • SPAN_MAP
  • SPAN_PARALLEL
  • SPAN_CHILD_CONTEXT

Motivation

Addresses reviewer feedback on #18191: span name strings should be constants rather than bare literals so they are defined in one place and typos are caught at import time.

Testing

No behavior change — span names are identical. Existing integration tests cover the affected code paths.

lym953 and others added 10 commits May 20, 2026 13:18
Add aws.durable.operation_retry_attempt to aws.durable.step and
aws.durable.wait_for_condition spans, sourced from the SDK's
StepDetails.attempt checkpoint field. 0 = original attempt, N = Nth
retry. Set as a numeric metric so it supports range queries.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…try_attempt

Match the style of the other span-attribute setters in the same
subscriber. The wire result is identical — _set_attribute dispatches by
value type, so an int still lands in the metrics dict as a float.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…-indexed in prod

The AWS Lambda Durable service reports `step_details.attempt` 1-indexed
(1 for the first attempt, 2 after the first retry), not 0-indexed like
the SDK's own documented semantic. Subtract 1 (clamped to 0) so the tag
emits the user-facing retry count: 0 for the original attempt, 1 for the
first retry, etc.

Updates the test_step_with_retry snapshot: the retry-success span's
value drops from 1 to 0 because the SDK testing framework already
returns step_details.attempt as the retry count directly. The test
framework and prod disagree on the semantics; the AIDEV-NOTE in
patch.py captures the discrepancy.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ttempt

Rename `aws.durable.operation_retry_attempt` to `aws.durable.operation_attempt`.
Semantics remain 0-indexed: 0 = original attempt, 1 = first retry, etc.

- TAG_OPERATION_RETRY_ATTEMPT renamed to TAG_OPERATION_ATTEMPT
- AwsDurableOperationEvent field renamed accordingly
- Snapshot keys updated; values unchanged

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…indexed

Match the AWS UI's attempt-count convention: 1 = original attempt,
2 = first retry, etc. Pass step_details.attempt through directly (it's
already 1-indexed in production); default to 1 when no checkpoint
exists yet, and clamp with max(1, …) to handle the SDK testing
framework's 0-indexed values.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…t tag

Switch aws.durable.operation_attempt to 0-indexed semantics: 0 = original
attempt, 1 = first retry, 2 = second retry, etc.

Production logging confirmed the server stores step_details.attempt as the
count of prior checkpointed attempts (0 when no checkpoint exists, 1 after
the first failure, etc.). Passing it through directly avoids the collision
where both the first and second attempt emitted 1 under the previous
max(1, attempt) logic. Both prod and the test framework use the same
underlying convention, so test and prod are now consistent.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…s in ext module

Replace bare "aws.durable.*" string literals in patch.py with named
constants imported from ddtrace/ext/aws_durable.py.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@lym953 lym953 added the changelog/no-changelog A changelog entry is not required for this PR. label Jun 1, 2026
@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Codeowners resolved as

ddtrace/contrib/internal/aws_durable_execution_sdk_python/patch.py      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/ext/aws_durable.py                                              @DataDog/apm-core-python @DataDog/apm-idm-python

@datadog-official

datadog-official Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 8 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741238-d2b8243-manylinux2014_x86_64, 1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build linux serverless: [amd64, cp315-cp315, v113741491-d2b8243-musllinux_1_2_x86_64, 1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build linux serverless: [arm64, cp315-cp315, v113741357-d2b8243-manylinux2014_aarch64, 1]   View in Datadog   GitLab

View all 8 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 664c9de | Docs | Datadog PR Page | Give us feedback!

@lym953
lym953 changed the base branch from main to yiming.luo/durable-retry-attempt June 1, 2026 17:15
@pr-commenter

pr-commenter Bot commented Jun 1, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-06-01 17:24:01

Comparing candidate commit 83aaa78 in PR branch yiming.luo/durable-span-name-const with baseline commit b4420fa in branch main.

Found 0 performance improvements and 2 performance regressions! Performance is the same for 385 metrics, 9 unstable metrics.

scenario:span-start

  • 🟥 execution_time [+1.171ms; +1.320ms] or [+7.464%; +8.416%]

scenario:telemetryaddmetric-1-count-metric-1-times

  • 🟥 execution_time [+204.962ns; +253.862ns] or [+9.407%; +11.652%]

@lym953 lym953 changed the title refactor(aws_durable_execution_sdk_python): define span name constants in ext module refactor(durable): [SVLS-9168] Extract operation span names as constants Jun 1, 2026
@lym953
lym953 marked this pull request as ready for review June 1, 2026 17:26
@lym953
lym953 requested review from a team as code owners June 1, 2026 17:26
@lym953
lym953 requested review from a team, emmettbutler, joeyzhao2018 and quinna-h and removed request for a team June 1, 2026 17:26

@emmettbutler emmettbutler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

Base automatically changed from yiming.luo/durable-retry-attempt to main June 4, 2026 14:33
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot requested review from a team as code owners June 4, 2026 14:33
@lym953

lym953 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jun 5, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-06-05 15:50:31 UTC ℹ️ Start processing command /merge


2026-06-05 15:50:37 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 58m (p90).


2026-06-05 16:43:01 UTCMergeQueue: The checks failed on this merge request

Tests failed on this commit 3e29909:

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.

@gh-worker-ownership-write-b05516
gh-worker-ownership-write-b05516 Bot removed request for a team June 5, 2026 16:53
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 18f19ee into main Jun 5, 2026
426 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the yiming.luo/durable-span-name-const branch June 5, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants