@@ -411,6 +411,9 @@ def test_func(event, context):
411
411
412
412
413
413
def test_partial_transaction (event_api , context , sending_elasticapm_client ):
414
+ import elasticapm .contrib .serverless .aws
415
+
416
+ elasticapm .contrib .serverless .aws .REGISTER_PARTIAL_TRANSACTIONS = True
414
417
os .environ ["AWS_LAMBDA_FUNCTION_NAME" ] = "test_func"
415
418
os .environ ["ELASTIC_APM_LAMBDA_APM_SERVER" ] = "http://localhost:8200"
416
419
@@ -427,3 +430,28 @@ def test_func(event, context):
427
430
assert b"metadata" in request .data
428
431
assert b"transaction" in request .data
429
432
sending_elasticapm_client .close ()
433
+
434
+
435
+ def test_partial_transaction_failure (event_api , context , sending_elasticapm_client ):
436
+ import elasticapm .contrib .serverless .aws
437
+
438
+ elasticapm .contrib .serverless .aws .REGISTER_PARTIAL_TRANSACTIONS = True
439
+ os .environ ["AWS_LAMBDA_FUNCTION_NAME" ] = "test_func"
440
+ os .environ ["ELASTIC_APM_LAMBDA_APM_SERVER" ] = "http://localhost:8200"
441
+ sending_elasticapm_client .httpserver .code = 404
442
+ sending_elasticapm_client .httpserver .content = "go away"
443
+
444
+ @capture_serverless
445
+ def test_func (event , context ):
446
+ return {"statusCode" : 200 , "headers" : {"foo" : "bar" }}
447
+
448
+ test_func (event_api , context )
449
+ test_func (event_api , context )
450
+
451
+ assert len (sending_elasticapm_client .httpserver .requests ) == 3
452
+ request = sending_elasticapm_client .httpserver .requests [0 ]
453
+ assert request .full_path == "/register/transaction?"
454
+ assert request .content_type == "application/vnd.elastic.apm.transaction+ndjson"
455
+ assert b"metadata" in request .data
456
+ assert b"transaction" in request .data
457
+ sending_elasticapm_client .close ()
0 commit comments