File tree 2 files changed +16
-1
lines changed
aws_lambda_powertools/tracing
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -622,14 +622,15 @@ def _is_tracer_disabled() -> bool:
622
622
"""
623
623
logger .debug ("Verifying whether Tracing has been disabled" )
624
624
is_lambda_sam_cli = os .getenv ("AWS_SAM_LOCAL" )
625
+ is_chalice_cli = os .getenv ("AWS_CHALICE_CLI_MODE" )
625
626
env_option = str (os .getenv ("POWERTOOLS_TRACE_DISABLED" , "false" ))
626
627
disabled_env = strtobool (env_option )
627
628
628
629
if disabled_env :
629
630
logger .debug ("Tracing has been disabled via env var POWERTOOLS_TRACE_DISABLED" )
630
631
return disabled_env
631
632
632
- if is_lambda_sam_cli :
633
+ if is_lambda_sam_cli or is_chalice_cli :
633
634
logger .debug ("Running under SAM CLI env or not in Lambda env; disabling Tracing" )
634
635
return True
635
636
Original file line number Diff line number Diff line change @@ -61,6 +61,20 @@ def handler(event, context):
61
61
handler ({}, {})
62
62
63
63
64
+ def test_tracer_chalice_cli_mode (monkeypatch , dummy_response ):
65
+ # GIVEN tracer runs locally
66
+ monkeypatch .setenv ("AWS_CHALICE_CLI_MODE" , "true" )
67
+ tracer = Tracer ()
68
+
69
+ # WHEN a lambda function is run through the Chalice CLI.
70
+ @tracer .capture_lambda_handler
71
+ def handler (event , context ):
72
+ return dummy_response
73
+
74
+ # THEN tracer should run in disabled mode, and not raise an Exception
75
+ handler ({}, {})
76
+
77
+
64
78
def test_tracer_metadata_disabled (dummy_response ):
65
79
# GIVEN tracer is disabled, and annotations/metadata are used
66
80
tracer = Tracer (disabled = True )
You can’t perform that action at this time.
0 commit comments