@@ -622,6 +622,7 @@ def test_step_function_trace_data(self):
622622 "Name" : "72a7ca3e-901c-41bb-b5a3-5f279b92a316" ,
623623 "RoleArn" : "arn:aws:iam::425362996713:role/service-role/StepFunctions-abhinav-activity-state-machine-role-22jpbgl6j" ,
624624 "StartTime" : "2024-12-04T19:38:04.069Z" ,
625+ "RedriveCount" : 0 ,
625626 },
626627 "State" : {
627628 "Name" : "Lambda Invoke" ,
@@ -657,6 +658,51 @@ def test_step_function_trace_data(self):
657658 expected_context ,
658659 )
659660
661+ @with_trace_propagation_style ("datadog" )
662+ def test_step_function_trace_data_retry (self ):
663+ lambda_ctx = get_mock_context ()
664+ sfn_event = {
665+ "Execution" : {
666+ "Id" : "arn:aws:states:sa-east-1:425362996713:execution:abhinav-activity-state-machine:72a7ca3e-901c-41bb-b5a3-5f279b92a316" ,
667+ "Name" : "72a7ca3e-901c-41bb-b5a3-5f279b92a316" ,
668+ "RoleArn" : "arn:aws:iam::425362996713:role/service-role/StepFunctions-abhinav-activity-state-machine-role-22jpbgl6j" ,
669+ "StartTime" : "2024-12-04T19:38:04.069Z" ,
670+ "RedriveCount" : 0 ,
671+ },
672+ "State" : {
673+ "Name" : "Lambda Invoke" ,
674+ "EnteredTime" : "2024-12-04T19:38:04.118Z" ,
675+ "RetryCount" : 1 ,
676+ },
677+ "StateMachine" : {
678+ "Id" : "arn:aws:states:sa-east-1:425362996713:stateMachine:abhinav-activity-state-machine" ,
679+ "Name" : "abhinav-activity-state-machine" ,
680+ },
681+ }
682+ ctx , source , event_source = extract_dd_trace_context (sfn_event , lambda_ctx )
683+ self .assertEqual (source , "event" )
684+ expected_context = Context (
685+ trace_id = 435175499815315247 ,
686+ span_id = 5063839446130725204 ,
687+ sampling_priority = 1 ,
688+ meta = {"_dd.p.tid" : "3e7a89d1b7310603" },
689+ )
690+ self .assertEqual (ctx , expected_context )
691+ self .assertEqual (
692+ get_dd_trace_context (),
693+ {
694+ TraceHeader .TRACE_ID : "435175499815315247" ,
695+ TraceHeader .PARENT_ID : "10713633173203262661" ,
696+ TraceHeader .SAMPLING_PRIORITY : "1" ,
697+ TraceHeader .TAGS : "_dd.p.tid=3e7a89d1b7310603" ,
698+ },
699+ )
700+ create_dd_dummy_metadata_subsegment (ctx , XraySubsegment .TRACE_KEY )
701+ self .mock_send_segment .assert_called_with (
702+ XraySubsegment .TRACE_KEY ,
703+ expected_context ,
704+ )
705+
660706 # https://github.com/DataDog/logs-backend/blob/c17618cb552fc369ca40282bae0a65803f82f694/domains/serverless/apps/logs-to-traces-reducer/src/test/resources/test-json-files/stepfunctions/RedriveTest/snapshots/RedriveLambdaSuccessTraceMerging.json#L46
661707 @with_trace_propagation_style ("datadog" )
662708 def test_step_function_trace_data_redrive (self ):
@@ -683,7 +729,7 @@ def test_step_function_trace_data_redrive(self):
683729 self .assertEqual (source , "event" )
684730 expected_context = Context (
685731 trace_id = 435175499815315247 ,
686- span_id = 5063839446130725204 ,
732+ span_id = 8782364156266188026 ,
687733 sampling_priority = 1 ,
688734 meta = {"_dd.p.tid" : "3e7a89d1b7310603" },
689735 )
@@ -716,6 +762,7 @@ def test_step_function_trace_data_lambda_root(self):
716762 "State" : {
717763 "Name" : "my-awesome-state" ,
718764 "EnteredTime" : "Mon Nov 13 12:43:33 PST 2023" ,
765+ "RetryCount" : 0 ,
719766 },
720767 "x-datadog-trace-id" : "5821803790426892636" ,
721768 "x-datadog-tags" : "_dd.p.dm=-0,_dd.p.tid=672a7cb100000000" ,
@@ -759,6 +806,7 @@ def test_step_function_trace_data_sfn_root(self):
759806 "State" : {
760807 "Name" : "my-awesome-state" ,
761808 "EnteredTime" : "Mon Nov 13 12:43:33 PST 2023" ,
809+ "RetryCount" : 0 ,
762810 },
763811 "RootExecutionId" : "4875aba4-ae31-4a4c-bf8a-63e9eee31dad" ,
764812 "serverless-version" : "v1" ,
0 commit comments