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:
661
661
662
662
def is_aws_arn (string_to_validate : Optional [str ]) -> bool :
663
663
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 23
23
create_step_function_span ,
24
24
get_current_ms_time ,
25
25
get_region ,
26
+ is_provision_concurrency_initialization ,
26
27
)
27
28
from lumigo_tracer import lumigo_utils
28
29
from lumigo_tracer .parsing_utils import parse_trace_id , safe_split_get , recursive_json_join
@@ -78,6 +79,7 @@ def __init__(
78
79
"info" : {"tracer" : {"version" : version }, "traceId" : {"Root" : trace_root }},
79
80
"token" : Configuration .token ,
80
81
}
82
+ is_cold = SpansContainer .is_cold and not is_provision_concurrency_initialization ()
81
83
self .function_span = recursive_json_join (
82
84
{
83
85
"id" : request_id ,
@@ -87,7 +89,7 @@ def __init__(
87
89
"event" : event ,
88
90
"envs" : envs ,
89
91
"memoryAllocated" : memory_allocated ,
90
- "readiness" : "cold" if SpansContainer . is_cold else "warm" ,
92
+ "readiness" : "cold" if is_cold else "warm" ,
91
93
"info" : {
92
94
"logStreamName" : log_stream_name ,
93
95
"logGroupName" : log_group_name ,
Original file line number Diff line number Diff line change @@ -96,6 +96,19 @@ def lambda_test_function(event, context):
96
96
assert span ["return_value" ] == '{"a": [1.0]}'
97
97
98
98
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
+
99
112
def test_kill_switch (monkeypatch , context ):
100
113
monkeypatch .setattr (os , "environ" , {"LUMIGO_SWITCH_OFF" : "true" })
101
114
You can’t perform that action at this time.
0 commit comments