File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -661,3 +661,7 @@ def is_error_code(status_code: int) -> bool:
661661
662662def is_aws_arn (string_to_validate : Optional [str ]) -> bool :
663663 return bool (string_to_validate and string_to_validate .startswith ("arn:aws:" ))
664+
665+
666+ def is_provision_concurrency_initialization () -> bool :
667+ return os .environ .get ("AWS_LAMBDA_INITIALIZATION_TYPE" ) == "provisioned-concurrency"
Original file line number Diff line number Diff line change 2323 create_step_function_span ,
2424 get_current_ms_time ,
2525 get_region ,
26+ is_provision_concurrency_initialization ,
2627)
2728from lumigo_tracer import lumigo_utils
2829from lumigo_tracer .parsing_utils import parse_trace_id , safe_split_get , recursive_json_join
@@ -78,6 +79,7 @@ def __init__(
7879 "info" : {"tracer" : {"version" : version }, "traceId" : {"Root" : trace_root }},
7980 "token" : Configuration .token ,
8081 }
82+ is_cold = SpansContainer .is_cold and not is_provision_concurrency_initialization ()
8183 self .function_span = recursive_json_join (
8284 {
8385 "id" : request_id ,
@@ -87,7 +89,7 @@ def __init__(
8789 "event" : event ,
8890 "envs" : envs ,
8991 "memoryAllocated" : memory_allocated ,
90- "readiness" : "cold" if SpansContainer . is_cold else "warm" ,
92+ "readiness" : "cold" if is_cold else "warm" ,
9193 "info" : {
9294 "logStreamName" : log_stream_name ,
9395 "logGroupName" : log_group_name ,
Original file line number Diff line number Diff line change @@ -96,6 +96,19 @@ def lambda_test_function(event, context):
9696 assert span ["return_value" ] == '{"a": [1.0]}'
9797
9898
99+ def test_lambda_wrapper_provision_concurrency_is_warm (context , monkeypatch ):
100+ monkeypatch .setattr (SpansContainer , "is_cold" , True )
101+ monkeypatch .setenv ("AWS_LAMBDA_INITIALIZATION_TYPE" , "provisioned-concurrency" )
102+
103+ @lumigo_tracer (token = "123" )
104+ def lambda_test_function (event , context ):
105+ return {"a" : "b" }
106+
107+ lambda_test_function ({}, context )
108+ span = SpansContainer .get_span ().function_span
109+ assert span ["readiness" ] == "warm"
110+
111+
99112def test_kill_switch (monkeypatch , context ):
100113 monkeypatch .setattr (os , "environ" , {"LUMIGO_SWITCH_OFF" : "true" })
101114
You can’t perform that action at this time.
0 commit comments