1
1
import pytest
2
2
3
- from tests .e2e .tracer .handlers import basic_handler , sync_async_capture
3
+ from tests .e2e .tracer .handlers import async_capture , basic_handler
4
4
from tests .e2e .tracer .infrastructure import TracerStack
5
5
from tests .e2e .utils import data_builder , data_fetcher
6
6
@@ -16,20 +16,25 @@ def basic_handler_fn(infrastructure: dict) -> str:
16
16
17
17
18
18
@pytest .fixture
19
- def sync_async_fn_arn (infrastructure : dict ) -> str :
20
- return infrastructure .get ("SyncAsyncCaptureArn " , "" )
19
+ def async_fn_arn (infrastructure : dict ) -> str :
20
+ return infrastructure .get ("AsyncCaptureArn " , "" )
21
21
22
22
23
23
@pytest .fixture
24
- def sync_async_fn (infrastructure : dict ) -> str :
25
- return infrastructure .get ("SyncAsyncCapture " , "" )
24
+ def async_fn (infrastructure : dict ) -> str :
25
+ return infrastructure .get ("AsyncCapture " , "" )
26
26
27
27
28
28
def test_lambda_handler_trace_is_visible (basic_handler_fn_arn : str , basic_handler_fn : str ):
29
29
# GIVEN
30
30
handler_name = basic_handler .lambda_handler .__name__
31
31
handler_subsegment = f"## { handler_name } "
32
32
handler_metadata_key = f"{ handler_name } response"
33
+
34
+ method_name = basic_handler .get_todos .__name__
35
+ method_subsegment = f"## { method_name } "
36
+ handler_metadata_key = f"{ method_name } response"
37
+
33
38
trace_query = data_builder .build_trace_default_query (function_name = basic_handler_fn )
34
39
35
40
# WHEN
@@ -41,29 +46,24 @@ def test_lambda_handler_trace_is_visible(basic_handler_fn_arn: str, basic_handle
41
46
42
47
assert len (trace .get_annotation (key = "ColdStart" , value = True )) == 1
43
48
assert len (trace .get_metadata (key = handler_metadata_key , namespace = TracerStack .SERVICE_NAME )) == 2
49
+ assert len (trace .get_metadata (key = handler_metadata_key , namespace = TracerStack .SERVICE_NAME )) == 2
44
50
assert len (trace .get_subsegment (name = handler_subsegment )) == 2
51
+ assert len (trace .get_subsegment (name = method_subsegment )) == 2
45
52
46
53
47
- def test_sync_async_capture_are_visible ( sync_async_fn_arn : str , sync_async_fn : str ):
54
+ def test_async_trace_is_visible ( async_fn_arn : str , async_fn : str ):
48
55
# GIVEN
49
- sync_fn_name = sync_async_capture .get_todos .__name__
50
- sync_fn_name_subsegment = f"## { sync_fn_name } "
51
- sync_fn_name_metadata_key = f"{ sync_fn_name } response"
52
-
53
- async_fn_name = sync_async_capture .async_get_users .__name__
56
+ async_fn_name = async_capture .async_get_users .__name__
54
57
async_fn_name_subsegment = f"## { async_fn_name } "
55
58
async_fn_name_metadata_key = f"{ async_fn_name } response"
56
59
57
- trace_query = data_builder .build_trace_default_query (function_name = sync_async_fn )
60
+ trace_query = data_builder .build_trace_default_query (function_name = async_fn )
58
61
59
62
# WHEN
60
- _ , execution_time = data_fetcher .get_lambda_response (lambda_arn = sync_async_fn_arn )
63
+ _ , execution_time = data_fetcher .get_lambda_response (lambda_arn = async_fn_arn )
61
64
62
65
# THEN
63
66
trace = data_fetcher .get_traces (start_date = execution_time , filter_expression = trace_query )
64
67
65
- assert len (trace .get_subsegment (name = sync_fn_name_subsegment )) == 1
66
- assert len (trace .get_metadata (key = sync_fn_name_metadata_key , namespace = TracerStack .SERVICE_NAME )) == 1
67
-
68
68
assert len (trace .get_subsegment (name = async_fn_name_subsegment )) == 1
69
69
assert len (trace .get_metadata (key = async_fn_name_metadata_key , namespace = TracerStack .SERVICE_NAME )) == 1
0 commit comments