@@ -67,7 +67,7 @@ def test_environment():
6767
6868 try :
6969 # Wait for SAM to be ready
70- LocalLambdaStack .wait_for_stack ()
70+ LocalLambdaStack .wait_for_stack (log_file = debug_log_file )
7171
7272 def before_test ():
7373 server .clear_envelopes ()
@@ -137,12 +137,12 @@ def test_basic_no_exception(lambda_client, test_environment):
137137 }
138138 assert transaction_event ["contexts" ]["trace" ] == {
139139 "op" : "function.aws" ,
140- "description" : mock .ANY ,
141140 "span_id" : mock .ANY ,
142141 "parent_span_id" : mock .ANY ,
143142 "trace_id" : mock .ANY ,
144143 "origin" : "auto.function.aws_lambda" ,
145144 "data" : mock .ANY ,
145+ "status" : "ok" ,
146146 }
147147
148148
@@ -178,7 +178,6 @@ def test_basic_exception(lambda_client, test_environment):
178178 }
179179 assert error_event ["contexts" ]["trace" ] == {
180180 "op" : "function.aws" ,
181- "description" : mock .ANY ,
182181 "span_id" : mock .ANY ,
183182 "parent_span_id" : mock .ANY ,
184183 "trace_id" : mock .ANY ,
@@ -314,9 +313,7 @@ def test_non_dict_event(
314313 "headers" : {"Host" : "x1.io" , "X-Forwarded-Proto" : "https" },
315314 "method" : "GET" ,
316315 "url" : "https://x1.io/1" ,
317- "query_string" : {
318- "done" : "f" ,
319- },
316+ "query_string" : "done=f" ,
320317 }
321318 else :
322319 request_data = {"url" : "awslambda:///BasicException" }
@@ -343,7 +340,8 @@ def test_request_data(lambda_client, test_environment):
343340 "X-Forwarded-Proto": "https"
344341 },
345342 "queryStringParameters": {
346- "bonkers": "true"
343+ "bonkers": "true",
344+ "wild": "false"
347345 },
348346 "pathParameters": null,
349347 "stageVariables": null,
@@ -373,7 +371,7 @@ def test_request_data(lambda_client, test_environment):
373371 "X-Forwarded-Proto" : "https" ,
374372 },
375373 "method" : "GET" ,
376- "query_string" : { "bonkers" : " true" } ,
374+ "query_string" : "bonkers= true&wild=false" ,
377375 "url" : "https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd" ,
378376 }
379377
@@ -457,7 +455,19 @@ def test_traces_sampler_has_correct_sampling_context(lambda_client, test_environ
457455 Test that aws_event and aws_context are passed in the custom_sampling_context
458456 when using the AWS Lambda integration.
459457 """
460- test_payload = {"test_key" : "test_value" }
458+ test_payload = {
459+ "test_key" : "test_value" ,
460+ "httpMethod" : "GET" ,
461+ "queryStringParameters" : {
462+ "test_query_param" : "test_query_value" ,
463+ },
464+ "path" : "/test" ,
465+ "headers" : {
466+ "X-Forwarded-Proto" : "https" ,
467+ "Host" : "example.com" ,
468+ "X-Bla" : "blabla" ,
469+ },
470+ }
461471 response = lambda_client .invoke (
462472 FunctionName = "TracesSampler" ,
463473 Payload = json .dumps (test_payload ),
@@ -466,9 +476,28 @@ def test_traces_sampler_has_correct_sampling_context(lambda_client, test_environ
466476 sampling_context_data = json .loads (response_payload ["body" ])[
467477 "sampling_context_data"
468478 ]
469- assert sampling_context_data .get ("aws_event_present" ) is True
470- assert sampling_context_data .get ("aws_context_present" ) is True
471- assert sampling_context_data .get ("event_data" , {}).get ("test_key" ) == "test_value"
479+
480+ assert sampling_context_data == {
481+ "transaction_context" : {
482+ "name" : "TracesSampler" ,
483+ "op" : "function.aws" ,
484+ "source" : "component" ,
485+ },
486+ "http.request.method" : "GET" ,
487+ "url.query" : "test_query_param=test_query_value" ,
488+ "url.path" : "/test" ,
489+ "url.full" : "https://example.com/test?test_query_param=test_query_value" ,
490+ "network.protocol.name" : "https" ,
491+ "server.address" : "example.com" ,
492+ "faas.name" : "TracesSampler" ,
493+ "http.request.header.x-forwarded-proto" : "https" ,
494+ "http.request.header.host" : "example.com" ,
495+ "http.request.header.x-bla" : "blabla" ,
496+ "sentry.op" : "function.aws" ,
497+ "sentry.source" : "component" ,
498+ "parent_sampled" : None ,
499+ "cloud.provider" : "aws" ,
500+ }
472501
473502
474503@pytest .mark .parametrize (
0 commit comments