diff --git a/ddtrace/_monkey.py b/ddtrace/_monkey.py index ac38ff5622..fb0a65a049 100644 --- a/ddtrace/_monkey.py +++ b/ddtrace/_monkey.py @@ -158,6 +158,8 @@ ), } +_NOT_PATCHABLE_VIA_ENVVAR = {"dd_trace_api"} + class PatchException(Exception): """Wraps regular `Exception` class when patching modules""" @@ -212,8 +214,7 @@ def on_import(hook): return on_import -def patch_all(**patch_modules): - # type: (bool) -> None +def patch_all(**patch_modules: bool) -> None: """Enables ddtrace library instrumentation. In addition to ``patch_modules``, an override can be specified via an @@ -230,7 +231,7 @@ def patch_all(**patch_modules): # The enabled setting can be overridden by environment variables for module, _enabled in modules.items(): env_var = "DD_TRACE_%s_ENABLED" % module.upper() - if env_var in os.environ: + if module not in _NOT_PATCHABLE_VIA_ENVVAR and env_var in os.environ: modules[module] = formats.asbool(os.environ[env_var]) # Enable all dependencies for the module