Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: re-vendor psutil and wrapt (backport #7332 to 2.0) #7436

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ddtrace/_monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import threading
from typing import TYPE_CHECKING

from wrapt.importer import when_imported
from ddtrace.vendor.wrapt.importer import when_imported

from .internal.compat import PY2
from .internal.logger import get_logger
Expand Down
5 changes: 3 additions & 2 deletions ddtrace/appsec/_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import json

from six import BytesIO
from wrapt import wrap_function_wrapper as _w
from wrapt.importer import when_imported
import xmltodict

from ddtrace import config
Expand All @@ -14,6 +12,8 @@
from ddtrace.internal import core
from ddtrace.internal.constants import HTTP_REQUEST_BLOCKED
from ddtrace.internal.logger import get_logger
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w
from ddtrace.vendor.wrapt.importer import when_imported


try:
Expand All @@ -22,6 +22,7 @@
# handling python 2.X import error
JSONDecodeError = ValueError # type: ignore


log = get_logger(__name__)
_BODY_METHODS = {"POST", "PUT", "DELETE", "PATCH"}

Expand Down
5 changes: 2 additions & 3 deletions ddtrace/appsec/_iast/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import sys
from typing import TYPE_CHECKING

from wrapt import FunctionWrapper
from wrapt import resolve_path

from ddtrace.internal.logger import get_logger
from ddtrace.vendor.wrapt import FunctionWrapper
from ddtrace.vendor.wrapt import resolve_path

from ._utils import _is_iast_enabled

Expand Down
2 changes: 1 addition & 1 deletion ddtrace/appsec/_iast/_patch_modules.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wrapt.importer import when_imported
from ddtrace.vendor.wrapt.importer import when_imported


IAST_PATCH = {
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/aiobotocore/patch.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os

import aiobotocore.client
import wrapt

from ddtrace import config
from ddtrace.internal.constants import COMPONENT
from ddtrace.internal.utils.version import parse_version
from ddtrace.vendor import wrapt

from ...constants import ANALYTICS_SAMPLE_RATE_KEY
from ...constants import SPAN_KIND
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/aiohttp/patch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os

import aiohttp
import wrapt
from yarl import URL

from ddtrace import config
Expand All @@ -11,6 +10,7 @@
from ddtrace.internal.schema.span_attribute_schema import SpanDirection
from ddtrace.internal.utils import get_argument_value
from ddtrace.internal.utils.formats import asbool
from ddtrace.vendor import wrapt

from ...ext import SpanKind
from ...ext import SpanTypes
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/aiomysql/patch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import aiomysql
import wrapt

from ddtrace import Pin
from ddtrace import config
Expand All @@ -10,6 +9,7 @@
from ddtrace.internal.constants import COMPONENT
from ddtrace.internal.schema import schematize_database_operation
from ddtrace.internal.utils.wrappers import unwrap
from ddtrace.vendor import wrapt

from ...ext import SpanKind
from ...ext import SpanTypes
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/aiopg/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from aiopg import __version__
from aiopg.utils import _ContextManager
import wrapt

from ddtrace import config
from ddtrace.constants import ANALYTICS_SAMPLE_RATE_KEY
Expand All @@ -17,6 +16,7 @@
from ddtrace.internal.schema import schematize_service_name
from ddtrace.internal.utils.version import parse_version
from ddtrace.pin import Pin
from ddtrace.vendor import wrapt


AIOPG_VERSION = parse_version(__version__)
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/aiopg/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

import aiopg.connection
import psycopg2.extensions
import wrapt

from ddtrace.contrib.aiopg.connection import AIOTracedConnection
from ddtrace.contrib.psycopg.connection import patch_conn as psycopg_patch_conn
from ddtrace.contrib.psycopg.extensions import _patch_extensions
from ddtrace.contrib.psycopg.extensions import _unpatch_extensions
from ddtrace.internal.utils.wrappers import unwrap as _u
from ddtrace.vendor import wrapt


def get_version():
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/aioredis/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import sys

import aioredis
from wrapt import wrap_function_wrapper as _w

from ddtrace import config
from ddtrace.internal.constants import COMPONENT
from ddtrace.internal.utils.wrappers import unwrap as _u
from ddtrace.pin import Pin
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w

from .. import trace_utils
from ...constants import ANALYTICS_SAMPLE_RATE_KEY
Expand Down
3 changes: 1 addition & 2 deletions ddtrace/contrib/algoliasearch/patch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from wrapt import wrap_function_wrapper as _w

from ddtrace import config
from ddtrace.ext import SpanKind
from ddtrace.ext import SpanTypes
Expand All @@ -8,6 +6,7 @@
from ddtrace.internal.schema import schematize_service_name
from ddtrace.internal.utils.wrappers import unwrap as _u
from ddtrace.pin import Pin
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w

from .. import trace_utils
from ...constants import SPAN_KIND
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/aredis/patch.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os

import aredis
import wrapt

from ddtrace import config
from ddtrace.vendor import wrapt

from ...internal.schema import schematize_service_name
from ...internal.utils.formats import CMD_MAX_LEN
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/asyncio/patch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import asyncio
import sys

from wrapt import ObjectProxy
from wrapt import wrap_function_wrapper as _w
from ddtrace.vendor.wrapt import ObjectProxy
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w

from ..trace_utils import unwrap as _u
from .wrappers import wrapped_create_task
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/asyncpg/patch.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import TYPE_CHECKING

import asyncpg
import wrapt

from ddtrace import Pin
from ddtrace import config
from ddtrace.internal.constants import COMPONENT
from ddtrace.vendor import wrapt

from ...constants import SPAN_KIND
from ...constants import SPAN_MEASURED_KEY
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/boto/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from boto import __version__
import boto.connection
import wrapt

from ddtrace import config
from ddtrace.constants import ANALYTICS_SAMPLE_RATE_KEY
Expand All @@ -16,6 +15,7 @@
from ddtrace.internal.constants import COMPONENT
from ddtrace.internal.utils.wrappers import unwrap
from ddtrace.pin import Pin
from ddtrace.vendor import wrapt

from ...internal.schema import schematize_cloud_api_operation
from ...internal.schema import schematize_service_name
Expand Down Expand Up @@ -140,7 +140,7 @@ def patched_auth_request(original_func, instance, args, kwargs):
# Go up the stack until we get the first non-ddtrace module
# DEV: For `lambda.list_functions()` this should be:
# - ddtrace.contrib.boto.patch
# - wrapt.wrappers
# - ddtrace.vendor.wrapt.wrappers
# - boto.awslambda.layer1 (make_request)
# - boto.awslambda.layer1 (list_functions)
# But can vary depending on Python versions; that's why we use an heuristic
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/botocore/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
from botocore import __version__
import botocore.client
import botocore.exceptions
import wrapt

from ddtrace import config
from ddtrace.internal.schema.span_attribute_schema import SpanDirection
from ddtrace.settings.config import Config
from ddtrace.vendor import wrapt

from ...constants import ANALYTICS_SAMPLE_RATE_KEY
from ...constants import SPAN_KIND
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/bottle/patch.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os

import bottle
import wrapt

from ddtrace import config
from ddtrace.vendor import wrapt

from ...internal.utils.formats import asbool
from .trace import TracePlugin
Expand Down
3 changes: 1 addition & 2 deletions ddtrace/contrib/cassandra/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
except AttributeError:
from cassandra import cluster as cassandra_cluster

import wrapt

from ddtrace import config
from ddtrace.internal.constants import COMPONENT

Expand All @@ -34,6 +32,7 @@
from ...internal.utils import get_argument_value
from ...internal.utils.formats import deep_getattr
from ...pin import Pin
from ...vendor import wrapt


log = get_logger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/consul/patch.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import consul
from wrapt import wrap_function_wrapper as _w

from ddtrace import config
from ddtrace.internal.constants import COMPONENT
from ddtrace.internal.schema.span_attribute_schema import SpanDirection
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w

from ...constants import ANALYTICS_SAMPLE_RATE_KEY
from ...constants import SPAN_KIND
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/dbapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Generic dbapi tracing code.
"""
import six
import wrapt

from ddtrace import config
from ddtrace.appsec._iast._utils import _is_iast_enabled
Expand All @@ -20,6 +19,7 @@
from ...internal.utils import ArgumentError
from ...internal.utils import get_argument_value
from ...pin import Pin
from ...vendor import wrapt
from ..trace_utils import ext_service
from ..trace_utils import iswrapped

Expand Down
5 changes: 2 additions & 3 deletions ddtrace/contrib/django/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
from inspect import isfunction
import os

import wrapt
from wrapt.importer import when_imported

from ddtrace import Pin
from ddtrace import config
from ddtrace.appsec import _asm_request_context
Expand All @@ -41,6 +38,8 @@
from ddtrace.internal.schema.span_attribute_schema import SpanDirection
from ddtrace.internal.utils.formats import asbool
from ddtrace.settings.integration import IntegrationConfig
from ddtrace.vendor import wrapt
from ddtrace.vendor.wrapt.importer import when_imported

from .. import trace_utils
from ...appsec._constants import WAF_CONTEXT_NAMES
Expand Down
3 changes: 2 additions & 1 deletion ddtrace/contrib/django/restframework.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import rest_framework.views
from wrapt import wrap_function_wrapper as wrap

from ddtrace.vendor.wrapt import wrap_function_wrapper as wrap

from ..trace_utils import iswrapped
from ..trace_utils import with_traced_module
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/django/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import django
from django.utils.functional import SimpleLazyObject
import six
from wrapt import FunctionWrapper
import xmltodict

from ddtrace import config
Expand All @@ -24,6 +23,7 @@
from ...internal import core
from ...internal.logger import get_logger
from ...internal.utils.formats import stringify_cache_args
from ...vendor.wrapt import FunctionWrapper
from .compat import get_resolver
from .compat import user_is_authenticated

Expand Down
3 changes: 1 addition & 2 deletions ddtrace/contrib/dogpile_cache/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
from dogpile import cache as dogpile_cache
from dogpile import lock as dogpile_lock

from wrapt import wrap_function_wrapper as _w

from ddtrace.internal.schema import schematize_service_name
from ddtrace.pin import Pin
from ddtrace.pin import _DD_PIN_NAME
from ddtrace.pin import _DD_PIN_PROXY_NAME
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w

from .lock import _wrap_lock_ctor
from .region import _wrap_get_create
Expand Down
3 changes: 1 addition & 2 deletions ddtrace/contrib/elasticsearch/patch.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from importlib import import_module
from typing import List

from wrapt import wrap_function_wrapper as _w

from ddtrace import config
from ddtrace._tracing import _limits
from ddtrace.contrib.trace_utils import ext_service
from ddtrace.contrib.trace_utils import extract_netloc_and_query_info_from_url
from ddtrace.ext import net
from ddtrace.internal.constants import COMPONENT
from ddtrace.internal.logger import get_logger
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w

from ...constants import ANALYTICS_SAMPLE_RATE_KEY
from ...constants import SPAN_KIND
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/contrib/falcon/patch.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os

import falcon
import wrapt

from ddtrace import config
from ddtrace import tracer
from ddtrace.vendor import wrapt

from ...internal.utils.formats import asbool
from ...internal.utils.version import parse_version
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/contrib/fastapi/patch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import fastapi
import fastapi.routing
from wrapt import ObjectProxy
from wrapt import wrap_function_wrapper as _w

from ddtrace import Pin
from ddtrace import config
Expand All @@ -10,6 +8,8 @@
from ddtrace.internal.logger import get_logger
from ddtrace.internal.schema import schematize_service_name
from ddtrace.internal.utils.wrappers import unwrap as _u
from ddtrace.vendor.wrapt import ObjectProxy
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w


log = get_logger(__name__)
Expand Down
3 changes: 1 addition & 2 deletions ddtrace/contrib/flask/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
except ImportError:
_HAS_JSON_MIXIN = False

from wrapt import wrap_function_wrapper as _w

from ddtrace import Pin
from ddtrace import config
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w

from ...contrib.wsgi.wsgi import _DDWSGIMiddlewareBase
from ...internal.logger import get_logger
Expand Down
Loading
Loading