prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  DeprecationWarning: the imp module is deprecated in favour of importlib
  When running a Django project using ddtrace with [warnings enabled](https://docs.python.org/3/using/cmdline.html#cmdoption-w), this warning is emitted:
  
  ## Issue
  
  > `/usr/local/lib/python3.7/dist-packages/ddtrace/bootstrap/sitecustomize.py:7`: `DeprecationWarning`: the `imp` module is deprecated in favour of `importlib`; see the [module's documentation](https://docs.python.org/3/library/imp.html) for alternative uses
  
  ## Details
  
  The line in question:
  
  https://github.com/DataDog/dd-trace-py/blob/94148324196eb41c1f6bef56be51bdd96c758fa7/ddtrace/bootstrap/sitecustomize.py#L7
  
  How it's used: 
  
  https://github.com/DataDog/dd-trace-py/blob/94148324196eb41c1f6bef56be51bdd96c758fa7/ddtrace/bootstrap/sitecustomize.py#L103-L120
  
  Documentation note for [`imp.find_module()`](https://docs.python.org/3/library/imp.html#imp.find_module):
  
  > Deprecated since version 3.3: Use `importlib.util.find_spec()` instead unless Python 3.3 compatibility is required, in which case use `importlib.find_loader()`. For example usage of the former case, see the Examples section of the `importlib` documentation.
  
  Documentation note for [`imp.load_module()`](https://docs.python.org/3/library/imp.html#imp.load_module):
  
  > Deprecated since version 3.3: If previously used in conjunction with `imp.find_module()` then consider using `importlib.import_module()`, otherwise use the loader returned by the replacement you chose for `imp.find_module()`. If you called `imp.load_module()` and related functions directly with file path arguments then use a combination of `importlib.util.spec_from_file_location()` and `importlib.util.module_from_spec()`. See the Examples section of the `importlib` documentation for details of the various approaches.
  
  ## Resolution
  
  I suspect [this example](https://docs.python.org/3/library/importlib.html#approximating-importlib-import-module) could be worth building off of to do the necessary path customization.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `ddtrace/bootstrap/sitecustomize.py`
  Content:
  ```
  1 """
  2 Bootstrapping code that is run when using the `ddtrace-run` Python entrypoint
  3 Add all monkey-patching that needs to run by default here
  4 """
  5 import logging
  6 import os
  7 import imp
  8 import sys
  9 
  10 from ddtrace.utils.formats import asbool, get_env, parse_tags_str
  11 from ddtrace.internal.logger import get_logger
  12 from ddtrace import config, constants
  13 from ddtrace.tracer import debug_mode, DD_LOG_FORMAT
  14 
  15 
  16 if config.logs_injection:
  17     # immediately patch logging if trace id injected
  18     from ddtrace import patch
  19 
  20     patch(logging=True)
  21 
  22 
  23 # DEV: Once basicConfig is called here, future calls to it cannot be used to
  24 # change the formatter since it applies the formatter to the root handler only
  25 # upon initializing it the first time.
  26 # See https://github.com/python/cpython/blob/112e4afd582515fcdcc0cde5012a4866e5cfda12/Lib/logging/__init__.py#L1550
  27 # Debug mode from the tracer will do a basicConfig so only need to do this otherwise
  28 if not debug_mode:
  29     if config.logs_injection:
  30         logging.basicConfig(format=DD_LOG_FORMAT)
  31     else:
  32         logging.basicConfig()
  33 
  34 log = get_logger(__name__)
  35 
  36 EXTRA_PATCHED_MODULES = {
  37     "bottle": True,
  38     "django": True,
  39     "falcon": True,
  40     "flask": True,
  41     "pylons": True,
  42     "pyramid": True,
  43 }
  44 
  45 
  46 def update_patched_modules():
  47     modules_to_patch = os.environ.get("DATADOG_PATCH_MODULES")
  48     if not modules_to_patch:
  49         return
  50 
  51     modules = parse_tags_str(modules_to_patch)
  52     for module, should_patch in modules.items():
  53         EXTRA_PATCHED_MODULES[module] = asbool(should_patch)
  54 
  55 
  56 try:
  57     from ddtrace import tracer
  58 
  59     # Respect DATADOG_* environment variables in global tracer configuration
  60     # TODO: these variables are deprecated; use utils method and update our documentation
  61     # correct prefix should be DD_*
  62     hostname = os.environ.get("DD_AGENT_HOST", os.environ.get("DATADOG_TRACE_AGENT_HOSTNAME"))
  63     port = os.environ.get("DATADOG_TRACE_AGENT_PORT")
  64     priority_sampling = os.environ.get("DATADOG_PRIORITY_SAMPLING")
  65     profiling = asbool(os.environ.get("DD_PROFILING_ENABLED", False))
  66 
  67     if profiling:
  68         import ddtrace.profiling.auto  # noqa: F401
  69 
  70     opts = {}
  71 
  72     if asbool(os.environ.get("DATADOG_TRACE_ENABLED", True)):
  73         patch = True
  74     else:
  75         patch = False
  76         opts["enabled"] = False
  77 
  78     if hostname:
  79         opts["hostname"] = hostname
  80     if port:
  81         opts["port"] = int(port)
  82     if priority_sampling:
  83         opts["priority_sampling"] = asbool(priority_sampling)
  84 
  85     opts["collect_metrics"] = asbool(get_env("runtime_metrics", "enabled"))
  86 
  87     if opts:
  88         tracer.configure(**opts)
  89 
  90     if patch:
  91         update_patched_modules()
  92         from ddtrace import patch_all
  93 
  94         patch_all(**EXTRA_PATCHED_MODULES)
  95 
  96     if "DATADOG_ENV" in os.environ:
  97         tracer.set_tags({constants.ENV_KEY: os.environ["DATADOG_ENV"]})
  98 
  99     if "DD_TRACE_GLOBAL_TAGS" in os.environ:
  100         env_tags = os.getenv("DD_TRACE_GLOBAL_TAGS")
  101         tracer.set_tags(parse_tags_str(env_tags))
  102 
  103     # Ensure sitecustomize.py is properly called if available in application directories:
  104     # * exclude `bootstrap_dir` from the search
  105     # * find a user `sitecustomize.py` module
  106     # * import that module via `imp`
  107     bootstrap_dir = os.path.dirname(__file__)
  108     path = list(sys.path)
  109 
  110     if bootstrap_dir in path:
  111         path.remove(bootstrap_dir)
  112 
  113     try:
  114         (f, path, description) = imp.find_module("sitecustomize", path)
  115     except ImportError:
  116         pass
  117     else:
  118         # `sitecustomize.py` found, load it
  119         log.debug("sitecustomize from user found in: %s", path)
  120         imp.load_module("sitecustomize", f, path, description)
  121 
  122     # Loading status used in tests to detect if the `sitecustomize` has been
  123     # properly loaded without exceptions. This must be the last action in the module
  124     # when the execution ends with a success.
  125     loaded = True
  126 except Exception:
  127     loaded = False
  128     log.warning("error configuring Datadog tracing", exc_info=True)
  129
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/ddtrace/bootstrap/sitecustomize.py b/ddtrace/bootstrap/sitecustomize.py
  --- a/ddtrace/bootstrap/sitecustomize.py
  +++ b/ddtrace/bootstrap/sitecustomize.py
  @@ -4,7 +4,6 @@
   """
   import logging
   import os
  -import imp
   import sys
   
   from ddtrace.utils.formats import asbool, get_env, parse_tags_str
  @@ -100,24 +99,40 @@
           env_tags = os.getenv("DD_TRACE_GLOBAL_TAGS")
           tracer.set_tags(parse_tags_str(env_tags))
   
  -    # Ensure sitecustomize.py is properly called if available in application directories:
  -    # * exclude `bootstrap_dir` from the search
  -    # * find a user `sitecustomize.py` module
  -    # * import that module via `imp`
  +    # Check for and import any sitecustomize that would have normally been used
  +    # had ddtrace-run not been used.
       bootstrap_dir = os.path.dirname(__file__)
  -    path = list(sys.path)
  -
  -    if bootstrap_dir in path:
  -        path.remove(bootstrap_dir)
  -
  -    try:
  -        (f, path, description) = imp.find_module("sitecustomize", path)
  -    except ImportError:
  -        pass
  +    if bootstrap_dir in sys.path:
  +        index = sys.path.index(bootstrap_dir)
  +        del sys.path[index]
  +
  +        # NOTE: this reference to the module is crucial in Python 2.
  +        # Without it the current module gets gc'd and all subsequent references
  +        # will be `None`.
  +        ddtrace_sitecustomize = sys.modules["sitecustomize"]
  +        del sys.modules["sitecustomize"]
  +        try:
  +            import sitecustomize  # noqa
  +        except ImportError:
  +            # If an additional sitecustomize is not found then put the ddtrace
  +            # sitecustomize back.
  +            log.debug("additional sitecustomize not found")
  +            sys.modules["sitecustomize"] = ddtrace_sitecustomize
  +        else:
  +            log.debug("additional sitecustomize found in: %s", sys.path)
  +        finally:
  +            # Always reinsert the ddtrace bootstrap directory to the path so
  +            # that introspection and debugging the application makes sense.
  +            # Note that this does not interfere with imports since a user
  +            # sitecustomize, if it exists, will be imported.
  +            sys.path.insert(index, bootstrap_dir)
       else:
  -        # `sitecustomize.py` found, load it
  -        log.debug("sitecustomize from user found in: %s", path)
  -        imp.load_module("sitecustomize", f, path, description)
  +        try:
  +            import sitecustomize  # noqa
  +        except ImportError:
  +            log.debug("additional sitecustomize not found")
  +        else:
  +            log.debug("additional sitecustomize found in: %s", sys.path)
   
       # Loading status used in tests to detect if the `sitecustomize` has been
       # properly loaded without exceptions. This must be the last action in the module
  
verification_info: {"golden_diff": "diff --git a/ddtrace/bootstrap/sitecustomize.py b/ddtrace/bootstrap/sitecustomize.py\n--- a/ddtrace/bootstrap/sitecustomize.py\n+++ b/ddtrace/bootstrap/sitecustomize.py\n@@ -4,7 +4,6 @@\n \"\"\"\n import logging\n import os\n-import imp\n import sys\n \n from ddtrace.utils.formats import asbool, get_env, parse_tags_str\n@@ -100,24 +99,40 @@\n         env_tags = os.getenv(\"DD_TRACE_GLOBAL_TAGS\")\n         tracer.set_tags(parse_tags_str(env_tags))\n \n-    # Ensure sitecustomize.py is properly called if available in application directories:\n-    # * exclude `bootstrap_dir` from the search\n-    # * find a user `sitecustomize.py` module\n-    # * import that module via `imp`\n+    # Check for and import any sitecustomize that would have normally been used\n+    # had ddtrace-run not been used.\n     bootstrap_dir = os.path.dirname(__file__)\n-    path = list(sys.path)\n-\n-    if bootstrap_dir in path:\n-        path.remove(bootstrap_dir)\n-\n-    try:\n-        (f, path, description) = imp.find_module(\"sitecustomize\", path)\n-    except ImportError:\n-        pass\n+    if bootstrap_dir in sys.path:\n+        index = sys.path.index(bootstrap_dir)\n+        del sys.path[index]\n+\n+        # NOTE: this reference to the module is crucial in Python 2.\n+        # Without it the current module gets gc'd and all subsequent references\n+        # will be `None`.\n+        ddtrace_sitecustomize = sys.modules[\"sitecustomize\"]\n+        del sys.modules[\"sitecustomize\"]\n+        try:\n+            import sitecustomize  # noqa\n+        except ImportError:\n+            # If an additional sitecustomize is not found then put the ddtrace\n+            # sitecustomize back.\n+            log.debug(\"additional sitecustomize not found\")\n+            sys.modules[\"sitecustomize\"] = ddtrace_sitecustomize\n+        else:\n+            log.debug(\"additional sitecustomize found in: %s\", sys.path)\n+        finally:\n+            # Always reinsert the ddtrace bootstrap directory to the path so\n+            # that introspection and debugging the application makes sense.\n+            # Note that this does not interfere with imports since a user\n+            # sitecustomize, if it exists, will be imported.\n+            sys.path.insert(index, bootstrap_dir)\n     else:\n-        # `sitecustomize.py` found, load it\n-        log.debug(\"sitecustomize from user found in: %s\", path)\n-        imp.load_module(\"sitecustomize\", f, path, description)\n+        try:\n+            import sitecustomize  # noqa\n+        except ImportError:\n+            log.debug(\"additional sitecustomize not found\")\n+        else:\n+            log.debug(\"additional sitecustomize found in: %s\", sys.path)\n \n     # Loading status used in tests to detect if the `sitecustomize` has been\n     # properly loaded without exceptions. This must be the last action in the module\n", "issue": "DeprecationWarning: the imp module is deprecated in favour of importlib\nWhen running a Django project using ddtrace with [warnings enabled](https://docs.python.org/3/using/cmdline.html#cmdoption-w), this warning is emitted:\r\n\r\n## Issue\r\n\r\n> `/usr/local/lib/python3.7/dist-packages/ddtrace/bootstrap/sitecustomize.py:7`: `DeprecationWarning`: the `imp` module is deprecated in favour of `importlib`; see the [module's documentation](https://docs.python.org/3/library/imp.html) for alternative uses\r\n\r\n## Details\r\n\r\nThe line in question:\r\n\r\nhttps://github.com/DataDog/dd-trace-py/blob/94148324196eb41c1f6bef56be51bdd96c758fa7/ddtrace/bootstrap/sitecustomize.py#L7\r\n\r\nHow it's used: \r\n\r\nhttps://github.com/DataDog/dd-trace-py/blob/94148324196eb41c1f6bef56be51bdd96c758fa7/ddtrace/bootstrap/sitecustomize.py#L103-L120\r\n\r\nDocumentation note for [`imp.find_module()`](https://docs.python.org/3/library/imp.html#imp.find_module):\r\n\r\n> Deprecated since version 3.3: Use `importlib.util.find_spec()` instead unless Python 3.3 compatibility is required, in which case use `importlib.find_loader()`. For example usage of the former case, see the Examples section of the `importlib` documentation.\r\n\r\nDocumentation note for [`imp.load_module()`](https://docs.python.org/3/library/imp.html#imp.load_module):\r\n\r\n> Deprecated since version 3.3: If previously used in conjunction with `imp.find_module()` then consider using `importlib.import_module()`, otherwise use the loader returned by the replacement you chose for `imp.find_module()`. If you called `imp.load_module()` and related functions directly with file path arguments then use a combination of `importlib.util.spec_from_file_location()` and `importlib.util.module_from_spec()`. See the Examples section of the `importlib` documentation for details of the various approaches.\r\n\r\n## Resolution\r\n\r\nI suspect [this example](https://docs.python.org/3/library/importlib.html#approximating-importlib-import-module) could be worth building off of to do the necessary path customization.\n", "before_files": [{"content": "\"\"\"\nBootstrapping code that is run when using the `ddtrace-run` Python entrypoint\nAdd all monkey-patching that needs to run by default here\n\"\"\"\nimport logging\nimport os\nimport imp\nimport sys\n\nfrom ddtrace.utils.formats import asbool, get_env, parse_tags_str\nfrom ddtrace.internal.logger import get_logger\nfrom ddtrace import config, constants\nfrom ddtrace.tracer import debug_mode, DD_LOG_FORMAT\n\n\nif config.logs_injection:\n    # immediately patch logging if trace id injected\n    from ddtrace import patch\n\n    patch(logging=True)\n\n\n# DEV: Once basicConfig is called here, future calls to it cannot be used to\n# change the formatter since it applies the formatter to the root handler only\n# upon initializing it the first time.\n# See https://github.com/python/cpython/blob/112e4afd582515fcdcc0cde5012a4866e5cfda12/Lib/logging/__init__.py#L1550\n# Debug mode from the tracer will do a basicConfig so only need to do this otherwise\nif not debug_mode:\n    if config.logs_injection:\n        logging.basicConfig(format=DD_LOG_FORMAT)\n    else:\n        logging.basicConfig()\n\nlog = get_logger(__name__)\n\nEXTRA_PATCHED_MODULES = {\n    \"bottle\": True,\n    \"django\": True,\n    \"falcon\": True,\n    \"flask\": True,\n    \"pylons\": True,\n    \"pyramid\": True,\n}\n\n\ndef update_patched_modules():\n    modules_to_patch = os.environ.get(\"DATADOG_PATCH_MODULES\")\n    if not modules_to_patch:\n        return\n\n    modules = parse_tags_str(modules_to_patch)\n    for module, should_patch in modules.items():\n        EXTRA_PATCHED_MODULES[module] = asbool(should_patch)\n\n\ntry:\n    from ddtrace import tracer\n\n    # Respect DATADOG_* environment variables in global tracer configuration\n    # TODO: these variables are deprecated; use utils method and update our documentation\n    # correct prefix should be DD_*\n    hostname = os.environ.get(\"DD_AGENT_HOST\", os.environ.get(\"DATADOG_TRACE_AGENT_HOSTNAME\"))\n    port = os.environ.get(\"DATADOG_TRACE_AGENT_PORT\")\n    priority_sampling = os.environ.get(\"DATADOG_PRIORITY_SAMPLING\")\n    profiling = asbool(os.environ.get(\"DD_PROFILING_ENABLED\", False))\n\n    if profiling:\n        import ddtrace.profiling.auto  # noqa: F401\n\n    opts = {}\n\n    if asbool(os.environ.get(\"DATADOG_TRACE_ENABLED\", True)):\n        patch = True\n    else:\n        patch = False\n        opts[\"enabled\"] = False\n\n    if hostname:\n        opts[\"hostname\"] = hostname\n    if port:\n        opts[\"port\"] = int(port)\n    if priority_sampling:\n        opts[\"priority_sampling\"] = asbool(priority_sampling)\n\n    opts[\"collect_metrics\"] = asbool(get_env(\"runtime_metrics\", \"enabled\"))\n\n    if opts:\n        tracer.configure(**opts)\n\n    if patch:\n        update_patched_modules()\n        from ddtrace import patch_all\n\n        patch_all(**EXTRA_PATCHED_MODULES)\n\n    if \"DATADOG_ENV\" in os.environ:\n        tracer.set_tags({constants.ENV_KEY: os.environ[\"DATADOG_ENV\"]})\n\n    if \"DD_TRACE_GLOBAL_TAGS\" in os.environ:\n        env_tags = os.getenv(\"DD_TRACE_GLOBAL_TAGS\")\n        tracer.set_tags(parse_tags_str(env_tags))\n\n    # Ensure sitecustomize.py is properly called if available in application directories:\n    # * exclude `bootstrap_dir` from the search\n    # * find a user `sitecustomize.py` module\n    # * import that module via `imp`\n    bootstrap_dir = os.path.dirname(__file__)\n    path = list(sys.path)\n\n    if bootstrap_dir in path:\n        path.remove(bootstrap_dir)\n\n    try:\n        (f, path, description) = imp.find_module(\"sitecustomize\", path)\n    except ImportError:\n        pass\n    else:\n        # `sitecustomize.py` found, load it\n        log.debug(\"sitecustomize from user found in: %s\", path)\n        imp.load_module(\"sitecustomize\", f, path, description)\n\n    # Loading status used in tests to detect if the `sitecustomize` has been\n    # properly loaded without exceptions. This must be the last action in the module\n    # when the execution ends with a success.\n    loaded = True\nexcept Exception:\n    loaded = False\n    log.warning(\"error configuring Datadog tracing\", exc_info=True)\n", "path": "ddtrace/bootstrap/sitecustomize.py"}], "after_files": [{"content": "\"\"\"\nBootstrapping code that is run when using the `ddtrace-run` Python entrypoint\nAdd all monkey-patching that needs to run by default here\n\"\"\"\nimport logging\nimport os\nimport sys\n\nfrom ddtrace.utils.formats import asbool, get_env, parse_tags_str\nfrom ddtrace.internal.logger import get_logger\nfrom ddtrace import config, constants\nfrom ddtrace.tracer import debug_mode, DD_LOG_FORMAT\n\n\nif config.logs_injection:\n    # immediately patch logging if trace id injected\n    from ddtrace import patch\n\n    patch(logging=True)\n\n\n# DEV: Once basicConfig is called here, future calls to it cannot be used to\n# change the formatter since it applies the formatter to the root handler only\n# upon initializing it the first time.\n# See https://github.com/python/cpython/blob/112e4afd582515fcdcc0cde5012a4866e5cfda12/Lib/logging/__init__.py#L1550\n# Debug mode from the tracer will do a basicConfig so only need to do this otherwise\nif not debug_mode:\n    if config.logs_injection:\n        logging.basicConfig(format=DD_LOG_FORMAT)\n    else:\n        logging.basicConfig()\n\nlog = get_logger(__name__)\n\nEXTRA_PATCHED_MODULES = {\n    \"bottle\": True,\n    \"django\": True,\n    \"falcon\": True,\n    \"flask\": True,\n    \"pylons\": True,\n    \"pyramid\": True,\n}\n\n\ndef update_patched_modules():\n    modules_to_patch = os.environ.get(\"DATADOG_PATCH_MODULES\")\n    if not modules_to_patch:\n        return\n\n    modules = parse_tags_str(modules_to_patch)\n    for module, should_patch in modules.items():\n        EXTRA_PATCHED_MODULES[module] = asbool(should_patch)\n\n\ntry:\n    from ddtrace import tracer\n\n    # Respect DATADOG_* environment variables in global tracer configuration\n    # TODO: these variables are deprecated; use utils method and update our documentation\n    # correct prefix should be DD_*\n    hostname = os.environ.get(\"DD_AGENT_HOST\", os.environ.get(\"DATADOG_TRACE_AGENT_HOSTNAME\"))\n    port = os.environ.get(\"DATADOG_TRACE_AGENT_PORT\")\n    priority_sampling = os.environ.get(\"DATADOG_PRIORITY_SAMPLING\")\n    profiling = asbool(os.environ.get(\"DD_PROFILING_ENABLED\", False))\n\n    if profiling:\n        import ddtrace.profiling.auto  # noqa: F401\n\n    opts = {}\n\n    if asbool(os.environ.get(\"DATADOG_TRACE_ENABLED\", True)):\n        patch = True\n    else:\n        patch = False\n        opts[\"enabled\"] = False\n\n    if hostname:\n        opts[\"hostname\"] = hostname\n    if port:\n        opts[\"port\"] = int(port)\n    if priority_sampling:\n        opts[\"priority_sampling\"] = asbool(priority_sampling)\n\n    opts[\"collect_metrics\"] = asbool(get_env(\"runtime_metrics\", \"enabled\"))\n\n    if opts:\n        tracer.configure(**opts)\n\n    if patch:\n        update_patched_modules()\n        from ddtrace import patch_all\n\n        patch_all(**EXTRA_PATCHED_MODULES)\n\n    if \"DATADOG_ENV\" in os.environ:\n        tracer.set_tags({constants.ENV_KEY: os.environ[\"DATADOG_ENV\"]})\n\n    if \"DD_TRACE_GLOBAL_TAGS\" in os.environ:\n        env_tags = os.getenv(\"DD_TRACE_GLOBAL_TAGS\")\n        tracer.set_tags(parse_tags_str(env_tags))\n\n    # Check for and import any sitecustomize that would have normally been used\n    # had ddtrace-run not been used.\n    bootstrap_dir = os.path.dirname(__file__)\n    if bootstrap_dir in sys.path:\n        index = sys.path.index(bootstrap_dir)\n        del sys.path[index]\n\n        # NOTE: this reference to the module is crucial in Python 2.\n        # Without it the current module gets gc'd and all subsequent references\n        # will be `None`.\n        ddtrace_sitecustomize = sys.modules[\"sitecustomize\"]\n        del sys.modules[\"sitecustomize\"]\n        try:\n            import sitecustomize  # noqa\n        except ImportError:\n            # If an additional sitecustomize is not found then put the ddtrace\n            # sitecustomize back.\n            log.debug(\"additional sitecustomize not found\")\n            sys.modules[\"sitecustomize\"] = ddtrace_sitecustomize\n        else:\n            log.debug(\"additional sitecustomize found in: %s\", sys.path)\n        finally:\n            # Always reinsert the ddtrace bootstrap directory to the path so\n            # that introspection and debugging the application makes sense.\n            # Note that this does not interfere with imports since a user\n            # sitecustomize, if it exists, will be imported.\n            sys.path.insert(index, bootstrap_dir)\n    else:\n        try:\n            import sitecustomize  # noqa\n        except ImportError:\n            log.debug(\"additional sitecustomize not found\")\n        else:\n            log.debug(\"additional sitecustomize found in: %s\", sys.path)\n\n    # Loading status used in tests to detect if the `sitecustomize` has been\n    # properly loaded without exceptions. This must be the last action in the module\n    # when the execution ends with a success.\n    loaded = True\nexcept Exception:\n    loaded = False\n    log.warning(\"error configuring Datadog tracing\", exc_info=True)\n", "path": "ddtrace/bootstrap/sitecustomize.py"}]}