@@ -2857,26 +2857,33 @@ def test_sns_to_sqs_event_with_malformed_datadog_message_attributes(
2857
2857
2858
2858
@patch ("datadog_lambda.tracing.extract_context_from_lambda_context" )
2859
2859
@patch ("datadog_lambda.tracing._dsm_set_checkpoint" )
2860
+ @patch ("ddtrace.data_streams.set_consume_checkpoint" )
2860
2861
def test_sqs_sns_event_with_exception_accessing_first_record (
2861
- self , mock_dsm_set_checkpoint , mock_extract_from_lambda_context
2862
+ self ,
2863
+ mock_set_consume_checkpoint ,
2864
+ mock_dsm_set_checkpoint ,
2865
+ mock_extract_from_lambda_context ,
2862
2866
):
2863
- event = {"Records" : None }
2867
+ event = {"Records" : None , "eventSource" : "aws:sqs" }
2864
2868
2865
2869
mock_context = Context (trace_id = 123 , span_id = 456 )
2866
2870
mock_extract_from_lambda_context .return_value = mock_context
2867
2871
2868
2872
result = extract_context_from_sqs_or_sns_event_or_context (
2869
2873
event , self .lambda_context , parse_event_source (event )
2870
2874
)
2871
-
2872
- mock_dsm_set_checkpoint .assert_not_called ()
2875
+ mock_set_consume_checkpoint .assert_not_called ()
2873
2876
mock_extract_from_lambda_context .assert_called_once_with (self .lambda_context )
2874
2877
self .assertEqual (result , mock_context )
2875
2878
2876
2879
@patch ("datadog_lambda.tracing.extract_context_from_lambda_context" )
2877
2880
@patch ("datadog_lambda.tracing._dsm_set_checkpoint" )
2881
+ @patch ("ddtrace.data_streams.set_consume_checkpoint" )
2878
2882
def test_sqs_event_with_empty_arn (
2879
- self , mock_dsm_set_checkpoint , mock_extract_from_lambda_context
2883
+ self ,
2884
+ mock_set_consume_checkpoint ,
2885
+ mock_dsm_set_checkpoint ,
2886
+ mock_extract_from_lambda_context ,
2880
2887
):
2881
2888
"""Test SQS event with empty eventSourceARN"""
2882
2889
event = {
@@ -2896,14 +2903,19 @@ def test_sqs_event_with_empty_arn(
2896
2903
event , self .lambda_context , parse_event_source (event )
2897
2904
)
2898
2905
2899
- mock_dsm_set_checkpoint .assert_not_called ()
2906
+ mock_dsm_set_checkpoint .assert_called_once_with (None , "sqs" , "" )
2907
+ mock_set_consume_checkpoint .assert_not_called ()
2900
2908
mock_extract_from_lambda_context .assert_called_once_with (self .lambda_context )
2901
2909
self .assertEqual (result , mock_context )
2902
2910
2903
2911
@patch ("datadog_lambda.tracing.extract_context_from_lambda_context" )
2904
2912
@patch ("datadog_lambda.tracing._dsm_set_checkpoint" )
2913
+ @patch ("ddtrace.data_streams.set_consume_checkpoint" )
2905
2914
def test_sns_event_with_empty_arn (
2906
- self , mock_dsm_set_checkpoint , mock_extract_from_lambda_context
2915
+ self ,
2916
+ mock_set_consume_checkpoint ,
2917
+ mock_dsm_set_checkpoint ,
2918
+ mock_extract_from_lambda_context ,
2907
2919
):
2908
2920
"""Test SNS event with empty TopicArn"""
2909
2921
event = {
@@ -2925,14 +2937,19 @@ def test_sns_event_with_empty_arn(
2925
2937
event , self .lambda_context , parse_event_source (event )
2926
2938
)
2927
2939
2928
- mock_dsm_set_checkpoint .assert_not_called ()
2940
+ mock_dsm_set_checkpoint .assert_called_once_with (None , "sns" , "" )
2941
+ mock_set_consume_checkpoint .assert_not_called ()
2929
2942
mock_extract_from_lambda_context .assert_called_once_with (self .lambda_context )
2930
2943
self .assertEqual (result , mock_context )
2931
2944
2932
2945
@patch ("datadog_lambda.tracing.extract_context_from_lambda_context" )
2933
2946
@patch ("datadog_lambda.tracing._dsm_set_checkpoint" )
2947
+ @patch ("ddtrace.data_streams.set_consume_checkpoint" )
2934
2948
def test_sns_to_sqs_event_with_empty_arn (
2935
- self , mock_dsm_set_checkpoint , mock_extract_from_lambda_context
2949
+ self ,
2950
+ mock_set_consume_checkpoint ,
2951
+ mock_dsm_set_checkpoint ,
2952
+ mock_extract_from_lambda_context ,
2936
2953
):
2937
2954
"""Test SNS->SQS event with empty eventSourceARN"""
2938
2955
sns_notification = {
@@ -2960,7 +2977,8 @@ def test_sns_to_sqs_event_with_empty_arn(
2960
2977
event , self .lambda_context , parse_event_source (event )
2961
2978
)
2962
2979
2963
- mock_dsm_set_checkpoint .assert_not_called ()
2980
+ mock_dsm_set_checkpoint .assert_called_once_with (None , "sqs" , "" )
2981
+ mock_set_consume_checkpoint .assert_not_called ()
2964
2982
mock_extract_from_lambda_context .assert_called_once_with (self .lambda_context )
2965
2983
self .assertEqual (result , mock_context )
2966
2984
@@ -3063,8 +3081,12 @@ def test_kinesis_event_with_malformed_data(
3063
3081
3064
3082
@patch ("datadog_lambda.tracing.extract_context_from_lambda_context" )
3065
3083
@patch ("datadog_lambda.tracing._dsm_set_checkpoint" )
3084
+ @patch ("ddtrace.data_streams.set_consume_checkpoint" )
3066
3085
def test_kinesis_event_with_empty_arn (
3067
- self , mock_dsm_set_checkpoint , mock_extract_from_lambda_context
3086
+ self ,
3087
+ mock_set_consume_checkpoint ,
3088
+ mock_dsm_set_checkpoint ,
3089
+ mock_extract_from_lambda_context ,
3068
3090
):
3069
3091
"""Test Kinesis event with empty eventSourceARN"""
3070
3092
kinesis_data = {"message" : "test" }
@@ -3085,22 +3107,21 @@ def test_kinesis_event_with_empty_arn(
3085
3107
3086
3108
result = extract_context_from_kinesis_event (event , self .lambda_context )
3087
3109
3088
- mock_dsm_set_checkpoint .assert_not_called ()
3110
+ mock_dsm_set_checkpoint .assert_called_once_with (None , "kinesis" , "" )
3111
+ mock_set_consume_checkpoint .assert_not_called ()
3089
3112
mock_extract_from_lambda_context .assert_called_once_with (self .lambda_context )
3090
3113
self .assertEqual (result , mock_context )
3091
3114
3092
3115
@patch ("datadog_lambda.tracing.extract_context_from_lambda_context" )
3093
- @patch ("datadog_lambda.tracing._dsm_set_checkpoint " )
3116
+ @patch ("ddtrace.data_streams.set_consume_checkpoint " )
3094
3117
def test_kinesis_event_with_exception_accessing_first_record (
3095
- self , mock_dsm_set_checkpoint , mock_extract_from_lambda_context
3118
+ self , mock_set_consume_checkpoint , mock_extract_from_lambda_context
3096
3119
):
3097
3120
event = {"Records" : None }
3098
3121
3099
3122
mock_context = Context (trace_id = 123 , span_id = 456 )
3100
3123
mock_extract_from_lambda_context .return_value = mock_context
3101
3124
3102
3125
result = extract_context_from_kinesis_event (event , self .lambda_context )
3103
-
3104
- mock_dsm_set_checkpoint .assert_not_called ()
3105
- mock_extract_from_lambda_context .assert_called_once_with (self .lambda_context )
3126
+ mock_set_consume_checkpoint .assert_not_called ()
3106
3127
self .assertEqual (result , mock_context )
0 commit comments