Skip to content

Commit

Permalink
chore: unvendor psutil and wrapt (#6651)
Browse files Browse the repository at this point in the history
We had vendored psutil in #1160 due to a lack of wheels for all support
architectures and OSes. This has since been resolved.

At the same time, we can also unvendor wrapt which was added in #755,
which also releases all wheels we need.

We pin the minimum version to the previously vendored version.

## Checklist

- [x] Change(s) are motivated and described in the PR description.
- [x] Testing strategy is described if automated tests are not included
in the PR.
- [x] Risk is outlined (performance impact, potential for breakage,
maintainability, etc).
- [x] Change is maintainable (easy to change, telemetry, documentation).
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed. If no release note is required, add label
`changelog/no-changelog`.
- [x] Documentation is included (in-code, generated user docs, [public
corp docs](https://github.com/DataDog/documentation/)).
- [x] Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist

- [x] Title is accurate.
- [x] No unnecessary changes are introduced.
- [x] Description motivates each change.
- [x] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes unless absolutely necessary.
- [x] Testing strategy adequately addresses listed risk(s).
- [x] Change is maintainable (easy to change, telemetry, documentation).
- [x] Release note makes sense to a user of the library.
- [x] Reviewer has explicitly acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment.
- [x] Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Emmett Butler <[email protected]>
  • Loading branch information
majorgreys and emmettbutler committed Sep 18, 2023
1 parent 914bbbb commit 231a799
Show file tree
Hide file tree
Showing 192 changed files with 160 additions and 35,132 deletions.
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 ddtrace.vendor.wrapt.importer import when_imported
from wrapt.importer import when_imported

from .internal.compat import PY2
from .internal.logger import get_logger
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/appsec/_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
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 @@ -12,8 +14,6 @@
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 Down
5 changes: 3 additions & 2 deletions ddtrace/appsec/_iast/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
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 ddtrace.vendor.wrapt.importer import when_imported
from 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,6 +1,7 @@
import os

import aiohttp
import wrapt
from yarl import URL

from ddtrace import config
Expand All @@ -10,7 +11,6 @@
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,4 +1,5 @@
import aiomysql
import wrapt

from ddtrace import Pin
from ddtrace import config
Expand All @@ -9,7 +10,6 @@
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,6 +2,7 @@

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 @@ -16,7 +17,6 @@
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: 2 additions & 1 deletion ddtrace/contrib/algoliasearch/patch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from wrapt import wrap_function_wrapper as _w

from ddtrace import config
from ddtrace.ext import SpanKind
from ddtrace.ext import SpanTypes
Expand All @@ -6,7 +8,6 @@
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 ddtrace.vendor.wrapt import ObjectProxy
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w
from wrapt import ObjectProxy
from 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,6 +3,7 @@

from boto import __version__
import boto.connection
import wrapt

from ddtrace import config
from ddtrace.constants import ANALYTICS_SAMPLE_RATE_KEY
Expand All @@ -15,7 +16,6 @@
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
# - ddtrace.vendor.wrapt.wrappers
# - 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: 2 additions & 1 deletion ddtrace/contrib/cassandra/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
except AttributeError:
from cassandra import cluster as cassandra_cluster

import wrapt

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

Expand All @@ -32,7 +34,6 @@
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,6 +2,7 @@
Generic dbapi tracing code.
"""
import six
import wrapt

from ddtrace import config
from ddtrace.appsec._iast._utils import _is_iast_enabled
Expand All @@ -19,7 +20,6 @@
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: 3 additions & 2 deletions ddtrace/contrib/django/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
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 @@ -38,8 +41,6 @@
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: 1 addition & 2 deletions ddtrace/contrib/django/restframework.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import rest_framework.views

from ddtrace.vendor.wrapt import wrap_function_wrapper as wrap
from 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,6 +9,7 @@
import django
from django.utils.functional import SimpleLazyObject
import six
from wrapt import FunctionWrapper
import xmltodict

from ddtrace import config
Expand All @@ -23,7 +24,6 @@
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: 2 additions & 1 deletion ddtrace/contrib/dogpile_cache/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
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: 2 additions & 1 deletion ddtrace/contrib/elasticsearch/patch.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
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,5 +1,7 @@
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 @@ -8,8 +10,6 @@
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: 2 additions & 1 deletion ddtrace/contrib/flask/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
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

0 comments on commit 231a799

Please sign in to comment.