Skip to content
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
4 changes: 0 additions & 4 deletions .github/workflows/test-integrations-dbs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ jobs:
run: |
set -x # print commands that are executed
./scripts/runtox.sh "py${{ matrix.python-version }}-redis"
- name: Test redis_py_cluster_legacy
run: |
set -x # print commands that are executed
./scripts/runtox.sh "py${{ matrix.python-version }}-redis_py_cluster_legacy"
- name: Test sqlalchemy
run: |
set -x # print commands that are executed
Expand Down
2 changes: 2 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh
- Dropped support for rq below 1.0.
- Dropped support for Quart below 0.19.
- Dropped support for Sanic below 22.0.
- Dropped support for redis-py below 4.2.
- Removed the RedisIntegration `max_data_size` option.
- Removed the possibility to supply a specific client to the LaunchDarklyIntegration.
- The `enable_tracing` option was removed. Use `traces_sample_rate=1.0` instead.
- The deprecated `push_scope` and `configure_scope` APIs have been removed. Use `with new_scope():` to push a new scope and `scope = get_current_scope()` to retrieve the current scope instead.
Expand Down
4 changes: 0 additions & 4 deletions scripts/populate_tox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,6 @@
"py3.7,py3.8": ["fakeredis<2.26.0"],
},
},
"redis_py_cluster_legacy": {
"package": "redis-py-cluster",
"num_versions": 2,
},
"requests": {
"package": "requests",
"num_versions": 2,
Expand Down
4 changes: 2 additions & 2 deletions scripts/populate_tox/package_dependencies.jsonl

Large diffs are not rendered by default.

13 changes: 1 addition & 12 deletions scripts/populate_tox/releases.jsonl

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion scripts/split_tox_gh_actions/split_tox_gh_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
"clickhouse_driver",
"pymongo",
"redis",
"redis_py_cluster_legacy",
"sqlalchemy",
],
"Flags": [
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def iter_default_integrations(
"pyreqwest": (0, 11, 6),
"quart": (0, 19, 0),
"ray": (2, 7, 0),
"redis": (2, 10, 0),
"redis": (4, 2, 0),
"requests": (2, 30, 0),
"rq": (1, 0),
"sanic": (22, 0),
Expand Down
23 changes: 2 additions & 21 deletions sentry_sdk/integrations/redis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import warnings
from typing import TYPE_CHECKING

from sentry_sdk.integrations import DidNotEnable, Integration, _check_minimum_version
from sentry_sdk.integrations.redis.consts import _DEFAULT_MAX_DATA_SIZE
from sentry_sdk.integrations.redis.rb import _patch_rb
from sentry_sdk.integrations.redis.redis import _patch_redis
from sentry_sdk.integrations.redis.redis_cluster import _patch_redis_cluster
from sentry_sdk.integrations.redis.redis_py_cluster_legacy import _patch_rediscluster
from sentry_sdk.utils import logger, parse_version
from sentry_sdk.utils import parse_version

if TYPE_CHECKING:
from typing import Optional
Expand All @@ -18,36 +15,20 @@ class RedisIntegration(Integration):

def __init__(
self,
max_data_size: "Optional[int]" = _DEFAULT_MAX_DATA_SIZE,
cache_prefixes: "Optional[list[str]]" = None,
) -> None:
self.max_data_size = max_data_size
self.cache_prefixes = cache_prefixes if cache_prefixes is not None else []

if max_data_size is not None:
warnings.warn(
"The `max_data_size` parameter of `RedisIntegration` is "
"deprecated and will be removed in version 3.0 of sentry-sdk.",
DeprecationWarning,
stacklevel=2,
)

@staticmethod
def setup_once() -> None:
try:
from redis import StrictRedis, client
from redis import __version__ as REDIS_VERSION
except ImportError:
raise DidNotEnable("Redis client not installed")

version = parse_version(REDIS_VERSION)
_check_minimum_version(RedisIntegration, version)

_patch_redis(StrictRedis, client)
_patch_redis()
_patch_redis_cluster()
_patch_rb()

try:
_patch_rediscluster()
except Exception:
logger.exception("Error occurred while patching `rediscluster` library")
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/redis/_async_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from collections.abc import Callable
from typing import Any, Optional, Union

from redis.asyncio.client import Pipeline, StrictRedis
from redis.asyncio.client import Pipeline, Redis
from redis.asyncio.cluster import ClusterPipeline, RedisCluster

from sentry_sdk.traces import StreamedSpan
Expand Down Expand Up @@ -87,7 +87,7 @@ async def _sentry_execute(self: "Any", *args: "Any", **kwargs: "Any") -> "Any":


def patch_redis_async_client(
cls: "Union[type[StrictRedis[Any]], type[RedisCluster[Any]]]",
cls: "Union[type[Redis[Any]], type[RedisCluster[Any]]]",
is_cluster: bool,
set_db_data_fn: "Callable[[Union[Span, StreamedSpan], Any], None]",
) -> None:
Expand Down
1 change: 0 additions & 1 deletion sentry_sdk/integrations/redis/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@
]
_MAX_NUM_ARGS = 10 # Trim argument lists to this many values
_MAX_NUM_COMMANDS = 10 # Trim command lists to this many values
_DEFAULT_MAX_DATA_SIZE = None
4 changes: 0 additions & 4 deletions sentry_sdk/integrations/redis/modules/caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ def _get_cache_span_description(
integration: "RedisIntegration",
) -> str:
description = _key_as_string(_get_safe_key(redis_command, args, kwargs))

if integration.max_data_size and len(description) > integration.max_data_size:
description = description[: integration.max_data_size - len("...")] + "..."

return description


Expand Down
3 changes: 0 additions & 3 deletions sentry_sdk/integrations/redis/modules/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ def _get_db_span_description(
with capture_internal_exceptions():
description = _get_safe_command(command_name, args)

if integration.max_data_size and len(description) > integration.max_data_size:
description = description[: integration.max_data_size - len("...")] + "..."

return description


Expand Down
54 changes: 20 additions & 34 deletions sentry_sdk/integrations/redis/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

from typing import TYPE_CHECKING

from sentry_sdk.integrations.redis._async_common import (
patch_redis_async_client,
patch_redis_async_pipeline,
)
from sentry_sdk.integrations.redis._sync_common import (
patch_redis_client,
patch_redis_pipeline,
Expand All @@ -20,9 +24,12 @@ def _get_redis_command_args(command: "Any") -> "Sequence[Any]":
return command[0]


def _patch_redis(StrictRedis: "Any", client: "Any") -> None: # noqa: N803
def _patch_redis() -> None:
import redis.asyncio
from redis import Redis, client

patch_redis_client(
StrictRedis,
Redis,
is_cluster=False,
set_db_data_fn=_set_db_data,
)
Expand All @@ -32,36 +39,15 @@ def _patch_redis(StrictRedis: "Any", client: "Any") -> None: # noqa: N803
get_command_args_fn=_get_redis_command_args,
set_db_data_fn=_set_db_data,
)
try:
strict_pipeline = client.StrictPipeline
except AttributeError:
pass
else:
patch_redis_pipeline(
strict_pipeline,
is_cluster=False,
get_command_args_fn=_get_redis_command_args,
set_db_data_fn=_set_db_data,
)

try:
import redis.asyncio
except ImportError:
pass
else:
from sentry_sdk.integrations.redis._async_common import (
patch_redis_async_client,
patch_redis_async_pipeline,
)

patch_redis_async_client(
redis.asyncio.client.StrictRedis,
is_cluster=False,
set_db_data_fn=_set_db_data,
)
patch_redis_async_pipeline(
redis.asyncio.client.Pipeline,
False,
_get_redis_command_args,
set_db_data_fn=_set_db_data,
)
patch_redis_async_client(
redis.asyncio.client.Redis,
is_cluster=False,
set_db_data_fn=_set_db_data,
)
patch_redis_async_pipeline(
redis.asyncio.client.Pipeline,
False,
_get_redis_command_args,
set_db_data_fn=_set_db_data,
)
49 changes: 0 additions & 49 deletions sentry_sdk/integrations/redis/redis_py_cluster_legacy.py

This file was deleted.

Loading
Loading