Skip to content

Commit fdaa71c

Browse files
committed
fix: if FLASK_DEBUG=0 or FLASK_ENV=production then don't enable
1 parent d09a9d1 commit fdaa71c

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

appmap/_implementation/detect_enabled.py

+18-9
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,34 @@ def detect_should_enable(cls, recording_method):
9191

9292
# it's flask
9393
message, should_enable = cls.is_flask_and_should_enable()
94-
if should_enable:
94+
if should_enable == True or should_enable == False:
9595
return [message, should_enable]
9696

9797
# it's django
9898
message, should_enable = cls.is_django_and_should_enable()
99-
if should_enable:
99+
if should_enable == True or should_enable == False:
100100
return [message, should_enable]
101101

102-
return ["it is not enabled by any configuration or framework", False]
102+
if recording_method in RECORDING_METHODS:
103+
return ["will record by default", True]
104+
105+
return ["it's not enabled by any configuration or framework", False]
103106

104107
@classmethod
105108
def is_flask_and_should_enable(cls):
106-
if "FLASK_DEBUG" in os.environ and os.environ["FLASK_DEBUG"] == "1":
107-
return [f"FLASK_DEBUG={os.environ['FLASK_DEBUG']}", True]
109+
if "FLASK_DEBUG" in os.environ:
110+
if os.environ["FLASK_DEBUG"] == "1":
111+
return [f"FLASK_DEBUG={os.environ['FLASK_DEBUG']}", True]
112+
elif os.environ["FLASK_DEBUG"] == "0":
113+
return [f"FLASK_DEBUG={os.environ['FLASK_DEBUG']}", False]
108114

109-
if "FLASK_ENV" in os.environ and os.environ["FLASK_ENV"] == "development":
110-
return [f"FLASK_ENV={os.environ['FLASK_ENV']}", True]
115+
if "FLASK_ENV" in os.environ:
116+
if os.environ["FLASK_ENV"] == "development":
117+
return [f"FLASK_ENV={os.environ['FLASK_ENV']}", True]
118+
elif os.environ["FLASK_ENV"] == "production":
119+
return [f"FLASK_ENV={os.environ['FLASK_ENV']}", False]
111120

112-
return ["it is not Flask", False]
121+
return ["it's not Flask", None]
113122

114123
@classmethod
115124
def is_django_and_should_enable(cls):
@@ -151,4 +160,4 @@ def is_django_and_should_enable(cls):
151160
# it wasn't set. it's ok
152161
pass
153162

154-
return ["it is not Django", False]
163+
return ["it's not Django", None]

0 commit comments

Comments
 (0)