Skip to content

Commit a0dff65

Browse files
committed
only use counts when both non-zero
1 parent a90fc76 commit a0dff65

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

datadog_lambda/tracing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,20 +389,20 @@ def _generate_sfn_parent_id(context: dict) -> int:
389389
upstream Step Function execution context is used to infer the parent's span ID, ensuring trace
390390
continuity.
391391
392-
`RetryCount` and `RedriveCount` are appended only when nonzero to maintain compatibility with
393-
older Lambda layers that did not include these fields
392+
`RetryCount` and `RedriveCount` are appended only when both are nonzero to maintain
393+
compatibility with older Lambda layers that did not include these fields.
394394
"""
395395
execution_id = context.get("Execution").get("Id")
396-
retry_count = context.get("Execution").get("RetryCount", 0)
397396
redrive_count = context.get("Execution").get("RedriveCount", 0)
398397
state_name = context.get("State").get("Name")
399398
state_entered_time = context.get("State").get("EnteredTime")
399+
retry_count = context.get("State").get("RetryCount", 0)
400400

401-
retry_postfix = "" if retry_count == 0 else f"#{retry_count}"
402-
redrive_postfix = "" if redrive_count == 0 else f"#{redrive_count}"
401+
include_counts = not (retry_count == 0 and redrive_count == 0)
402+
counts_suffix = f"#{retry_count}#{redrive_count}" if include_counts else ""
403403

404404
return _deterministic_sha256_hash(
405-
f"{execution_id}#{state_name}#{state_entered_time}{retry_postfix}{redrive_postfix}",
405+
f"{execution_id}#{state_name}#{state_entered_time}{counts_suffix}",
406406
HIGHER_64_BITS,
407407
)
408408

0 commit comments

Comments
 (0)