@@ -619,30 +619,83 @@ def test_step_function_trace_data(self):
619
619
lambda_ctx = get_mock_context ()
620
620
sfn_event = {
621
621
"Execution" : {
622
- "Id" : "665c417c-1237-4742-aaca-8b3becbb9e75" ,
622
+ "Id" : "arn:aws:states:sa-east-1:425362996713:execution:abhinav-activity-state-machine:72a7ca3e-901c-41bb-b5a3-5f279b92a316" ,
623
+ "Name" : "72a7ca3e-901c-41bb-b5a3-5f279b92a316" ,
624
+ "RoleArn" : "arn:aws:iam::425362996713:role/service-role/StepFunctions-abhinav-activity-state-machine-role-22jpbgl6j" ,
625
+ "StartTime" : "2024-12-04T19:38:04.069Z" ,
623
626
},
624
- "StateMachine" : {},
625
627
"State" : {
626
- "Name" : "my-awesome-state" ,
627
- "EnteredTime" : "Mon Nov 13 12:43:33 PST 2023" ,
628
+ "Name" : "Lambda Invoke" ,
629
+ "EnteredTime" : "2024-12-04T19:38:04.118Z" ,
630
+ "RetryCount" : 0 ,
631
+ },
632
+ "StateMachine" : {
633
+ "Id" : "arn:aws:states:sa-east-1:425362996713:stateMachine:abhinav-activity-state-machine" ,
634
+ "Name" : "abhinav-activity-state-machine" ,
628
635
},
629
636
}
630
637
ctx , source , event_source = extract_dd_trace_context (sfn_event , lambda_ctx )
631
638
self .assertEqual (source , "event" )
632
639
expected_context = Context (
633
- trace_id = 3675572987363469717 ,
634
- span_id = 6880978411788117524 ,
640
+ trace_id = 435175499815315247 ,
641
+ span_id = 3929055471293792800 ,
642
+ sampling_priority = 1 ,
643
+ meta = {"_dd.p.tid" : "3e7a89d1b7310603" },
644
+ )
645
+ self .assertEqual (ctx , expected_context )
646
+ self .assertEqual (
647
+ get_dd_trace_context (),
648
+ {
649
+ TraceHeader .TRACE_ID : "435175499815315247" ,
650
+ TraceHeader .PARENT_ID : "10713633173203262661" ,
651
+ TraceHeader .SAMPLING_PRIORITY : "1" ,
652
+ TraceHeader .TAGS : "_dd.p.tid=3e7a89d1b7310603" ,
653
+ },
654
+ )
655
+ create_dd_dummy_metadata_subsegment (ctx , XraySubsegment .TRACE_KEY )
656
+ self .mock_send_segment .assert_called_with (
657
+ XraySubsegment .TRACE_KEY ,
658
+ expected_context ,
659
+ )
660
+
661
+ # 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
662
+ @with_trace_propagation_style ("datadog" )
663
+ def test_step_function_trace_data_redrive (self ):
664
+ lambda_ctx = get_mock_context ()
665
+ sfn_event = {
666
+ "Execution" : {
667
+ "Id" : "arn:aws:states:sa-east-1:425362996713:execution:abhinav-activity-state-machine:72a7ca3e-901c-41bb-b5a3-5f279b92a316" ,
668
+ "Name" : "72a7ca3e-901c-41bb-b5a3-5f279b92a316" ,
669
+ "RoleArn" : "arn:aws:iam::425362996713:role/service-role/StepFunctions-abhinav-activity-state-machine-role-22jpbgl6j" ,
670
+ "StartTime" : "2024-12-04T19:38:04.069Z" ,
671
+ "RedriveCount" : 1 ,
672
+ },
673
+ "State" : {
674
+ "Name" : "Lambda Invoke" ,
675
+ "EnteredTime" : "2024-12-04T19:38:04.118Z" ,
676
+ "RetryCount" : 0 ,
677
+ },
678
+ "StateMachine" : {
679
+ "Id" : "arn:aws:states:sa-east-1:425362996713:stateMachine:abhinav-activity-state-machine" ,
680
+ "Name" : "abhinav-activity-state-machine" ,
681
+ },
682
+ }
683
+ ctx , source , event_source = extract_dd_trace_context (sfn_event , lambda_ctx )
684
+ self .assertEqual (source , "event" )
685
+ expected_context = Context (
686
+ trace_id = 435175499815315247 ,
687
+ span_id = 5063839446130725204 ,
635
688
sampling_priority = 1 ,
636
- meta = {"_dd.p.tid" : "e987c84b36b11ab " },
689
+ meta = {"_dd.p.tid" : "3e7a89d1b7310603 " },
637
690
)
638
691
self .assertEqual (ctx , expected_context )
639
692
self .assertEqual (
640
693
get_dd_trace_context (),
641
694
{
642
- TraceHeader .TRACE_ID : "3675572987363469717 " ,
695
+ TraceHeader .TRACE_ID : "435175499815315247 " ,
643
696
TraceHeader .PARENT_ID : "10713633173203262661" ,
644
697
TraceHeader .SAMPLING_PRIORITY : "1" ,
645
- TraceHeader .TAGS : "_dd.p.tid=e987c84b36b11ab " ,
698
+ TraceHeader .TAGS : "_dd.p.tid=3e7a89d1b7310603 " ,
646
699
},
647
700
)
648
701
create_dd_dummy_metadata_subsegment (ctx , XraySubsegment .TRACE_KEY )
@@ -658,6 +711,7 @@ def test_step_function_trace_data_lambda_root(self):
658
711
"_datadog" : {
659
712
"Execution" : {
660
713
"Id" : "665c417c-1237-4742-aaca-8b3becbb9e75" ,
714
+ "RedriveCount" : 0 ,
661
715
},
662
716
"StateMachine" : {},
663
717
"State" : {
@@ -700,6 +754,7 @@ def test_step_function_trace_data_sfn_root(self):
700
754
"_datadog" : {
701
755
"Execution" : {
702
756
"Id" : "665c417c-1237-4742-aaca-8b3becbb9e75" ,
757
+ "RedriveCount" : 0 ,
703
758
},
704
759
"StateMachine" : {},
705
760
"State" : {
0 commit comments