@@ -336,6 +336,33 @@ def handler(event, context):
336
336
assert second_log ["cold_start" ] is False
337
337
338
338
339
+ def test_inject_lambda_cold_start_with_provisioned_concurrency (monkeypatch , lambda_context , stdout , service_name ):
340
+
341
+ # GIVEN Provisioned Concurrency is enabled via AWS_LAMBDA_INITIALIZATION_TYPE environment variable
342
+ # AND Logger's cold start flag is explicitly set to True (simulating fresh module import)
343
+ monkeypatch .setenv ("AWS_LAMBDA_INITIALIZATION_TYPE" , "provisioned-concurrency" )
344
+ from aws_lambda_powertools .logging import logger
345
+
346
+ logger .is_cold_start = True
347
+
348
+ # GIVEN Logger is initialized
349
+ logger = Logger (service = service_name , stream = stdout )
350
+
351
+ # WHEN a lambda function is decorated with logger, and called twice
352
+ @logger .inject_lambda_context
353
+ def handler (event , context ):
354
+ logger .info ("Hello" )
355
+
356
+ handler ({}, lambda_context )
357
+ handler ({}, lambda_context )
358
+
359
+ # THEN cold_start should be False in both invocations
360
+ # because Provisioned Concurrency environment variable forces cold_start to always be False
361
+ first_log , second_log = capture_multiple_logging_statements_output (stdout )
362
+ assert first_log ["cold_start" ] is False
363
+ assert second_log ["cold_start" ] is False
364
+
365
+
339
366
def test_logger_append_duplicated (stdout , service_name ):
340
367
# GIVEN Logger is initialized with request_id field
341
368
logger = Logger (service = service_name , stream = stdout , request_id = "value" )
0 commit comments