Skip to content

Commit

Permalink
disallow configuring dd_trace_api patching via envvars
Browse files Browse the repository at this point in the history
  • Loading branch information
emmettbutler committed Feb 6, 2025
1 parent 8620f4c commit ff23412
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ddtrace/_monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@
),
}

_NOT_PATCHABLE_VIA_ENVVAR = {"dd_trace_api"}


class PatchException(Exception):
"""Wraps regular `Exception` class when patching modules"""
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ff23412

Please sign in to comment.