|
36 | 36 |
|
37 | 37 | from elasticapm import capture_span
|
38 | 38 | from elasticapm.conf import constants
|
39 |
| -from elasticapm.contrib.serverless.aws import capture_serverless, get_data_from_request, get_data_from_response |
| 39 | +from elasticapm.contrib.serverless.aws import ( |
| 40 | + capture_serverless, |
| 41 | + get_data_from_request, |
| 42 | + get_data_from_response, |
| 43 | + should_normalize_headers, |
| 44 | +) |
40 | 45 |
|
41 | 46 |
|
42 | 47 | @pytest.fixture
|
@@ -300,6 +305,7 @@ def test_func(event, context):
|
300 | 305 | assert transaction["context"]["request"]["headers"]
|
301 | 306 | assert transaction["context"]["response"]["status_code"] == 200
|
302 | 307 | assert transaction["context"]["service"]["origin"]["name"] == "lambda-279XGJDqGZ5rsrHC2Fjr"
|
| 308 | + assert transaction["trace_id"] == "12345678901234567890123456789012" |
303 | 309 |
|
304 | 310 |
|
305 | 311 | def test_capture_serverless_s3(event_s3, context, elasticapm_client):
|
@@ -477,3 +483,17 @@ def test_func(event, context):
|
477 | 483 |
|
478 | 484 | test_func(event_api2, context)
|
479 | 485 | assert len(elasticapm_client.events[constants.TRANSACTION]) == 1
|
| 486 | + |
| 487 | + |
| 488 | +def test_should_normalize_headers_true(event_api, event_elb): |
| 489 | + assert should_normalize_headers(event_api) is True |
| 490 | + assert should_normalize_headers(event_elb) is True |
| 491 | + |
| 492 | + |
| 493 | +def test_should_normalize_headers_false(event_api2, event_lurl, event_s3, event_s3_batch, event_sqs, event_sns): |
| 494 | + assert should_normalize_headers(event_api2) is False |
| 495 | + assert should_normalize_headers(event_lurl) is False |
| 496 | + assert should_normalize_headers(event_s3) is False |
| 497 | + assert should_normalize_headers(event_s3_batch) is False |
| 498 | + assert should_normalize_headers(event_sqs) is False |
| 499 | + assert should_normalize_headers(event_sns) is False |
0 commit comments