Skip to content

Commit ff23412

Browse files
committed
disallow configuring dd_trace_api patching via envvars
1 parent 8620f4c commit ff23412

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ddtrace/_monkey.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@
158158
),
159159
}
160160

161+
_NOT_PATCHABLE_VIA_ENVVAR = {"dd_trace_api"}
162+
161163

162164
class PatchException(Exception):
163165
"""Wraps regular `Exception` class when patching modules"""
@@ -212,8 +214,7 @@ def on_import(hook):
212214
return on_import
213215

214216

215-
def patch_all(**patch_modules):
216-
# type: (bool) -> None
217+
def patch_all(**patch_modules: bool) -> None:
217218
"""Enables ddtrace library instrumentation.
218219
219220
In addition to ``patch_modules``, an override can be specified via an
@@ -230,7 +231,7 @@ def patch_all(**patch_modules):
230231
# The enabled setting can be overridden by environment variables
231232
for module, _enabled in modules.items():
232233
env_var = "DD_TRACE_%s_ENABLED" % module.upper()
233-
if env_var in os.environ:
234+
if module not in _NOT_PATCHABLE_VIA_ENVVAR and env_var in os.environ:
234235
modules[module] = formats.asbool(os.environ[env_var])
235236

236237
# Enable all dependencies for the module

0 commit comments

Comments
 (0)