@@ -2857,26 +2857,33 @@ def test_sns_to_sqs_event_with_malformed_datadog_message_attributes(
28572857
28582858 @patch ("datadog_lambda.tracing.extract_context_from_lambda_context" )
28592859 @patch ("datadog_lambda.tracing._dsm_set_checkpoint" )
2860+ @patch ("ddtrace.data_streams.set_consume_checkpoint" )
28602861 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 ,
28622866 ):
2863- event = {"Records" : None }
2867+ event = {"Records" : None , "eventSource" : "aws:sqs" }
28642868
28652869 mock_context = Context (trace_id = 123 , span_id = 456 )
28662870 mock_extract_from_lambda_context .return_value = mock_context
28672871
28682872 result = extract_context_from_sqs_or_sns_event_or_context (
28692873 event , self .lambda_context , parse_event_source (event )
28702874 )
2871-
2872- mock_dsm_set_checkpoint .assert_not_called ()
2875+ mock_set_consume_checkpoint .assert_not_called ()
28732876 mock_extract_from_lambda_context .assert_called_once_with (self .lambda_context )
28742877 self .assertEqual (result , mock_context )
28752878
28762879 @patch ("datadog_lambda.tracing.extract_context_from_lambda_context" )
28772880 @patch ("datadog_lambda.tracing._dsm_set_checkpoint" )
2881+ @patch ("ddtrace.data_streams.set_consume_checkpoint" )
28782882 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 ,
28802887 ):
28812888 """Test SQS event with empty eventSourceARN"""
28822889 event = {
@@ -2896,14 +2903,19 @@ def test_sqs_event_with_empty_arn(
28962903 event , self .lambda_context , parse_event_source (event )
28972904 )
28982905
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 ()
29002908 mock_extract_from_lambda_context .assert_called_once_with (self .lambda_context )
29012909 self .assertEqual (result , mock_context )
29022910
29032911 @patch ("datadog_lambda.tracing.extract_context_from_lambda_context" )
29042912 @patch ("datadog_lambda.tracing._dsm_set_checkpoint" )
2913+ @patch ("ddtrace.data_streams.set_consume_checkpoint" )
29052914 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 ,
29072919 ):
29082920 """Test SNS event with empty TopicArn"""
29092921 event = {
@@ -2925,14 +2937,19 @@ def test_sns_event_with_empty_arn(
29252937 event , self .lambda_context , parse_event_source (event )
29262938 )
29272939
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 ()
29292942 mock_extract_from_lambda_context .assert_called_once_with (self .lambda_context )
29302943 self .assertEqual (result , mock_context )
29312944
29322945 @patch ("datadog_lambda.tracing.extract_context_from_lambda_context" )
29332946 @patch ("datadog_lambda.tracing._dsm_set_checkpoint" )
2947+ @patch ("ddtrace.data_streams.set_consume_checkpoint" )
29342948 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 ,
29362953 ):
29372954 """Test SNS->SQS event with empty eventSourceARN"""
29382955 sns_notification = {
@@ -2960,7 +2977,8 @@ def test_sns_to_sqs_event_with_empty_arn(
29602977 event , self .lambda_context , parse_event_source (event )
29612978 )
29622979
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 ()
29642982 mock_extract_from_lambda_context .assert_called_once_with (self .lambda_context )
29652983 self .assertEqual (result , mock_context )
29662984
@@ -3063,8 +3081,12 @@ def test_kinesis_event_with_malformed_data(
30633081
30643082 @patch ("datadog_lambda.tracing.extract_context_from_lambda_context" )
30653083 @patch ("datadog_lambda.tracing._dsm_set_checkpoint" )
3084+ @patch ("ddtrace.data_streams.set_consume_checkpoint" )
30663085 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 ,
30683090 ):
30693091 """Test Kinesis event with empty eventSourceARN"""
30703092 kinesis_data = {"message" : "test" }
@@ -3085,22 +3107,21 @@ def test_kinesis_event_with_empty_arn(
30853107
30863108 result = extract_context_from_kinesis_event (event , self .lambda_context )
30873109
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 ()
30893112 mock_extract_from_lambda_context .assert_called_once_with (self .lambda_context )
30903113 self .assertEqual (result , mock_context )
30913114
30923115 @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 " )
30943117 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
30963119 ):
30973120 event = {"Records" : None }
30983121
30993122 mock_context = Context (trace_id = 123 , span_id = 456 )
31003123 mock_extract_from_lambda_context .return_value = mock_context
31013124
31023125 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 ()
31063127 self .assertEqual (result , mock_context )
0 commit comments