We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Redis integration tests have side effects
### How do you use Sentry?

Self-hosted/on-premise

### Version

1.9.2

### Steps to Reproduce

While working on https://github.com/getsentry/sentry-python/pull/1543, I noticed the following:

1. Checked out `sentry-sdk` for development.
2. Installed redis:
    ```
    fakeredis==1.9.0
    redis==3.5.3
    redis-py-cluster==2.1.3
    ````
3. Run redis integration tests twice, in different order:
    ```bash
    # first rediscluster, then redis
    pytest 'tests/integrations/rediscluster/test_rediscluster.py::test_rediscluster_basic[RedisCluster]' tests/integrations/redis/test_redis.py::test_basic
    # first redis, then rediscluster
    pytest tests/integrations/redis/test_redis.py::test_basic 'tests/integrations/rediscluster/test_rediscluster.py::test_rediscluster_basic[RedisCluster]'

### Expected Result

Both test runs pass.

### Actual Result

The second test run

```bash
pytest tests/integrations/redis/test_redis.py::test_basic 'tests/integrations/rediscluster/test_rediscluster.py::test_rediscluster_basic[RedisCluster]' 
```

fails with 

```pytest
tests/integrations/redis/test_redis.py .                                                                                                                                                                                                                                                    [ 50%]
tests/integrations/rediscluster/test_rediscluster.py F                                                                                                                                                                                                                                      [100%]

============================================================================================================================================ FAILURES =============================================================================================================================================
______________________________________________________________________________________________________________________________ test_rediscluster_basic[RedisCluster] ______________________________________________________________________________________________________________________________
tests/integrations/rediscluster/test_rediscluster.py:29: in test_rediscluster_basic
    (crumb,) = event["breadcrumbs"]["values"]
E   ValueError: not enough values to unpack (expected 1, got 0)
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sentry_sdk/integrations/redis.py`
Content:
```
1 from __future__ import absolute_import
2 
3 from sentry_sdk import Hub
4 from sentry_sdk.utils import capture_internal_exceptions, logger
5 from sentry_sdk.integrations import Integration, DidNotEnable
6 
7 from sentry_sdk._types import MYPY
8 
9 if MYPY:
10     from typing import Any, Sequence
11 
12 _SINGLE_KEY_COMMANDS = frozenset(
13     ["decr", "decrby", "get", "incr", "incrby", "pttl", "set", "setex", "setnx", "ttl"]
14 )
15 _MULTI_KEY_COMMANDS = frozenset(["del", "touch", "unlink"])
16 
17 #: Trim argument lists to this many values
18 _MAX_NUM_ARGS = 10
19 
20 
21 def patch_redis_pipeline(pipeline_cls, is_cluster, get_command_args_fn):
22     # type: (Any, bool, Any) -> None
23     old_execute = pipeline_cls.execute
24 
25     def sentry_patched_execute(self, *args, **kwargs):
26         # type: (Any, *Any, **Any) -> Any
27         hub = Hub.current
28 
29         if hub.get_integration(RedisIntegration) is None:
30             return old_execute(self, *args, **kwargs)
31 
32         with hub.start_span(op="redis", description="redis.pipeline.execute") as span:
33             with capture_internal_exceptions():
34                 span.set_tag("redis.is_cluster", is_cluster)
35                 transaction = self.transaction if not is_cluster else False
36                 span.set_tag("redis.transaction", transaction)
37 
38                 commands = []
39                 for i, arg in enumerate(self.command_stack):
40                     if i > _MAX_NUM_ARGS:
41                         break
42                     command_args = []
43                     for j, command_arg in enumerate(get_command_args_fn(arg)):
44                         if j > 0:
45                             command_arg = repr(command_arg)
46                         command_args.append(command_arg)
47                     commands.append(" ".join(command_args))
48 
49                 span.set_data(
50                     "redis.commands",
51                     {"count": len(self.command_stack), "first_ten": commands},
52                 )
53 
54             return old_execute(self, *args, **kwargs)
55 
56     pipeline_cls.execute = sentry_patched_execute
57 
58 
59 def _get_redis_command_args(command):
60     # type: (Any) -> Sequence[Any]
61     return command[0]
62 
63 
64 def _parse_rediscluster_command(command):
65     # type: (Any) -> Sequence[Any]
66     return command.args
67 
68 
69 def _patch_rediscluster():
70     # type: () -> None
71     try:
72         import rediscluster  # type: ignore
73     except ImportError:
74         return
75 
76     patch_redis_client(rediscluster.RedisCluster, is_cluster=True)
77 
78     # up to v1.3.6, __version__ attribute is a tuple
79     # from v2.0.0, __version__ is a string and VERSION a tuple
80     version = getattr(rediscluster, "VERSION", rediscluster.__version__)
81 
82     # StrictRedisCluster was introduced in v0.2.0 and removed in v2.0.0
83     # https://github.com/Grokzen/redis-py-cluster/blob/master/docs/release-notes.rst
84     if (0, 2, 0) < version < (2, 0, 0):
85         pipeline_cls = rediscluster.StrictClusterPipeline
86         patch_redis_client(rediscluster.StrictRedisCluster, is_cluster=True)
87     else:
88         pipeline_cls = rediscluster.ClusterPipeline
89 
90     patch_redis_pipeline(pipeline_cls, True, _parse_rediscluster_command)
91 
92 
93 class RedisIntegration(Integration):
94     identifier = "redis"
95 
96     @staticmethod
97     def setup_once():
98         # type: () -> None
99         try:
100             import redis
101         except ImportError:
102             raise DidNotEnable("Redis client not installed")
103 
104         patch_redis_client(redis.StrictRedis, is_cluster=False)
105         patch_redis_pipeline(redis.client.Pipeline, False, _get_redis_command_args)
106         try:
107             strict_pipeline = redis.client.StrictPipeline  # type: ignore
108         except AttributeError:
109             pass
110         else:
111             patch_redis_pipeline(strict_pipeline, False, _get_redis_command_args)
112 
113         try:
114             import rb.clients  # type: ignore
115         except ImportError:
116             pass
117         else:
118             patch_redis_client(rb.clients.FanoutClient, is_cluster=False)
119             patch_redis_client(rb.clients.MappingClient, is_cluster=False)
120             patch_redis_client(rb.clients.RoutingClient, is_cluster=False)
121 
122         try:
123             _patch_rediscluster()
124         except Exception:
125             logger.exception("Error occurred while patching `rediscluster` library")
126 
127 
128 def patch_redis_client(cls, is_cluster):
129     # type: (Any, bool) -> None
130     """
131     This function can be used to instrument custom redis client classes or
132     subclasses.
133     """
134 
135     old_execute_command = cls.execute_command
136 
137     def sentry_patched_execute_command(self, name, *args, **kwargs):
138         # type: (Any, str, *Any, **Any) -> Any
139         hub = Hub.current
140 
141         if hub.get_integration(RedisIntegration) is None:
142             return old_execute_command(self, name, *args, **kwargs)
143 
144         description = name
145 
146         with capture_internal_exceptions():
147             description_parts = [name]
148             for i, arg in enumerate(args):
149                 if i > _MAX_NUM_ARGS:
150                     break
151 
152                 description_parts.append(repr(arg))
153 
154             description = " ".join(description_parts)
155 
156         with hub.start_span(op="redis", description=description) as span:
157             span.set_tag("redis.is_cluster", is_cluster)
158             if name:
159                 span.set_tag("redis.command", name)
160 
161             if name and args:
162                 name_low = name.lower()
163                 if (name_low in _SINGLE_KEY_COMMANDS) or (
164                     name_low in _MULTI_KEY_COMMANDS and len(args) == 1
165                 ):
166                     span.set_tag("redis.key", args[0])
167 
168             return old_execute_command(self, name, *args, **kwargs)
169 
170     cls.execute_command = sentry_patched_execute_command
171
```
--- 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()

```

diff --git a/sentry_sdk/integrations/redis.py b/sentry_sdk/integrations/redis.py
--- a/sentry_sdk/integrations/redis.py
+++ b/sentry_sdk/integrations/redis.py
@@ -131,7 +131,6 @@
     This function can be used to instrument custom redis client classes or
     subclasses.
     """
-
     old_execute_command = cls.execute_command
 
     def sentry_patched_execute_command(self, name, *args, **kwargs):

{"golden_diff": "diff --git a/sentry_sdk/integrations/redis.py b/sentry_sdk/integrations/redis.py\n--- a/sentry_sdk/integrations/redis.py\n+++ b/sentry_sdk/integrations/redis.py\n@@ -131,7 +131,6 @@\n     This function can be used to instrument custom redis client classes or\n     subclasses.\n     \"\"\"\n-\n     old_execute_command = cls.execute_command\n \n     def sentry_patched_execute_command(self, name, *args, **kwargs):\n", "issue": "Redis integration tests have side effects\n### How do you use Sentry?\n\nSelf-hosted/on-premise\n\n### Version\n\n1.9.2\n\n### Steps to Reproduce\n\nWhile working on https://github.com/getsentry/sentry-python/pull/1543, I noticed the following:\r\n\r\n1. Checked out `sentry-sdk` for development.\r\n2. Installed redis:\r\n    ```\r\n    fakeredis==1.9.0\r\n    redis==3.5.3\r\n    redis-py-cluster==2.1.3\r\n    ````\r\n3. Run redis integration tests twice, in different order:\r\n    ```bash\r\n    # first rediscluster, then redis\r\n    pytest 'tests/integrations/rediscluster/test_rediscluster.py::test_rediscluster_basic[RedisCluster]' tests/integrations/redis/test_redis.py::test_basic\r\n    # first redis, then rediscluster\r\n    pytest tests/integrations/redis/test_redis.py::test_basic 'tests/integrations/rediscluster/test_rediscluster.py::test_rediscluster_basic[RedisCluster]'\n\n### Expected Result\n\nBoth test runs pass.\n\n### Actual Result\n\nThe second test run\r\n\r\n```bash\r\npytest tests/integrations/redis/test_redis.py::test_basic 'tests/integrations/rediscluster/test_rediscluster.py::test_rediscluster_basic[RedisCluster]' \r\n```\r\n\r\nfails with \r\n\r\n```pytest\r\ntests/integrations/redis/test_redis.py .                                                                                                                                                                                                                                                    [ 50%]\r\ntests/integrations/rediscluster/test_rediscluster.py F                                                                                                                                                                                                                                      [100%]\r\n\r\n============================================================================================================================================ FAILURES =============================================================================================================================================\r\n______________________________________________________________________________________________________________________________ test_rediscluster_basic[RedisCluster] ______________________________________________________________________________________________________________________________\r\ntests/integrations/rediscluster/test_rediscluster.py:29: in test_rediscluster_basic\r\n    (crumb,) = event[\"breadcrumbs\"][\"values\"]\r\nE   ValueError: not enough values to unpack (expected 1, got 0)\r\n```\n", "before_files": [{"content": "from __future__ import absolute_import\n\nfrom sentry_sdk import Hub\nfrom sentry_sdk.utils import capture_internal_exceptions, logger\nfrom sentry_sdk.integrations import Integration, DidNotEnable\n\nfrom sentry_sdk._types import MYPY\n\nif MYPY:\n    from typing import Any, Sequence\n\n_SINGLE_KEY_COMMANDS = frozenset(\n    [\"decr\", \"decrby\", \"get\", \"incr\", \"incrby\", \"pttl\", \"set\", \"setex\", \"setnx\", \"ttl\"]\n)\n_MULTI_KEY_COMMANDS = frozenset([\"del\", \"touch\", \"unlink\"])\n\n#: Trim argument lists to this many values\n_MAX_NUM_ARGS = 10\n\n\ndef patch_redis_pipeline(pipeline_cls, is_cluster, get_command_args_fn):\n    # type: (Any, bool, Any) -> None\n    old_execute = pipeline_cls.execute\n\n    def sentry_patched_execute(self, *args, **kwargs):\n        # type: (Any, *Any, **Any) -> Any\n        hub = Hub.current\n\n        if hub.get_integration(RedisIntegration) is None:\n            return old_execute(self, *args, **kwargs)\n\n        with hub.start_span(op=\"redis\", description=\"redis.pipeline.execute\") as span:\n            with capture_internal_exceptions():\n                span.set_tag(\"redis.is_cluster\", is_cluster)\n                transaction = self.transaction if not is_cluster else False\n                span.set_tag(\"redis.transaction\", transaction)\n\n                commands = []\n                for i, arg in enumerate(self.command_stack):\n                    if i > _MAX_NUM_ARGS:\n                        break\n                    command_args = []\n                    for j, command_arg in enumerate(get_command_args_fn(arg)):\n                        if j > 0:\n                            command_arg = repr(command_arg)\n                        command_args.append(command_arg)\n                    commands.append(\" \".join(command_args))\n\n                span.set_data(\n                    \"redis.commands\",\n                    {\"count\": len(self.command_stack), \"first_ten\": commands},\n                )\n\n            return old_execute(self, *args, **kwargs)\n\n    pipeline_cls.execute = sentry_patched_execute\n\n\ndef _get_redis_command_args(command):\n    # type: (Any) -> Sequence[Any]\n    return command[0]\n\n\ndef _parse_rediscluster_command(command):\n    # type: (Any) -> Sequence[Any]\n    return command.args\n\n\ndef _patch_rediscluster():\n    # type: () -> None\n    try:\n        import rediscluster  # type: ignore\n    except ImportError:\n        return\n\n    patch_redis_client(rediscluster.RedisCluster, is_cluster=True)\n\n    # up to v1.3.6, __version__ attribute is a tuple\n    # from v2.0.0, __version__ is a string and VERSION a tuple\n    version = getattr(rediscluster, \"VERSION\", rediscluster.__version__)\n\n    # StrictRedisCluster was introduced in v0.2.0 and removed in v2.0.0\n    # https://github.com/Grokzen/redis-py-cluster/blob/master/docs/release-notes.rst\n    if (0, 2, 0) < version < (2, 0, 0):\n        pipeline_cls = rediscluster.StrictClusterPipeline\n        patch_redis_client(rediscluster.StrictRedisCluster, is_cluster=True)\n    else:\n        pipeline_cls = rediscluster.ClusterPipeline\n\n    patch_redis_pipeline(pipeline_cls, True, _parse_rediscluster_command)\n\n\nclass RedisIntegration(Integration):\n    identifier = \"redis\"\n\n    @staticmethod\n    def setup_once():\n        # type: () -> None\n        try:\n            import redis\n        except ImportError:\n            raise DidNotEnable(\"Redis client not installed\")\n\n        patch_redis_client(redis.StrictRedis, is_cluster=False)\n        patch_redis_pipeline(redis.client.Pipeline, False, _get_redis_command_args)\n        try:\n            strict_pipeline = redis.client.StrictPipeline  # type: ignore\n        except AttributeError:\n            pass\n        else:\n            patch_redis_pipeline(strict_pipeline, False, _get_redis_command_args)\n\n        try:\n            import rb.clients  # type: ignore\n        except ImportError:\n            pass\n        else:\n            patch_redis_client(rb.clients.FanoutClient, is_cluster=False)\n            patch_redis_client(rb.clients.MappingClient, is_cluster=False)\n            patch_redis_client(rb.clients.RoutingClient, is_cluster=False)\n\n        try:\n            _patch_rediscluster()\n        except Exception:\n            logger.exception(\"Error occurred while patching `rediscluster` library\")\n\n\ndef patch_redis_client(cls, is_cluster):\n    # type: (Any, bool) -> None\n    \"\"\"\n    This function can be used to instrument custom redis client classes or\n    subclasses.\n    \"\"\"\n\n    old_execute_command = cls.execute_command\n\n    def sentry_patched_execute_command(self, name, *args, **kwargs):\n        # type: (Any, str, *Any, **Any) -> Any\n        hub = Hub.current\n\n        if hub.get_integration(RedisIntegration) is None:\n            return old_execute_command(self, name, *args, **kwargs)\n\n        description = name\n\n        with capture_internal_exceptions():\n            description_parts = [name]\n            for i, arg in enumerate(args):\n                if i > _MAX_NUM_ARGS:\n                    break\n\n                description_parts.append(repr(arg))\n\n            description = \" \".join(description_parts)\n\n        with hub.start_span(op=\"redis\", description=description) as span:\n            span.set_tag(\"redis.is_cluster\", is_cluster)\n            if name:\n                span.set_tag(\"redis.command\", name)\n\n            if name and args:\n                name_low = name.lower()\n                if (name_low in _SINGLE_KEY_COMMANDS) or (\n                    name_low in _MULTI_KEY_COMMANDS and len(args) == 1\n                ):\n                    span.set_tag(\"redis.key\", args[0])\n\n            return old_execute_command(self, name, *args, **kwargs)\n\n    cls.execute_command = sentry_patched_execute_command\n", "path": "sentry_sdk/integrations/redis.py"}], "after_files": [{"content": "from __future__ import absolute_import\n\nfrom sentry_sdk import Hub\nfrom sentry_sdk.utils import capture_internal_exceptions, logger\nfrom sentry_sdk.integrations import Integration, DidNotEnable\n\nfrom sentry_sdk._types import MYPY\n\nif MYPY:\n    from typing import Any, Sequence\n\n_SINGLE_KEY_COMMANDS = frozenset(\n    [\"decr\", \"decrby\", \"get\", \"incr\", \"incrby\", \"pttl\", \"set\", \"setex\", \"setnx\", \"ttl\"]\n)\n_MULTI_KEY_COMMANDS = frozenset([\"del\", \"touch\", \"unlink\"])\n\n#: Trim argument lists to this many values\n_MAX_NUM_ARGS = 10\n\n\ndef patch_redis_pipeline(pipeline_cls, is_cluster, get_command_args_fn):\n    # type: (Any, bool, Any) -> None\n    old_execute = pipeline_cls.execute\n\n    def sentry_patched_execute(self, *args, **kwargs):\n        # type: (Any, *Any, **Any) -> Any\n        hub = Hub.current\n\n        if hub.get_integration(RedisIntegration) is None:\n            return old_execute(self, *args, **kwargs)\n\n        with hub.start_span(op=\"redis\", description=\"redis.pipeline.execute\") as span:\n            with capture_internal_exceptions():\n                span.set_tag(\"redis.is_cluster\", is_cluster)\n                transaction = self.transaction if not is_cluster else False\n                span.set_tag(\"redis.transaction\", transaction)\n\n                commands = []\n                for i, arg in enumerate(self.command_stack):\n                    if i > _MAX_NUM_ARGS:\n                        break\n                    command_args = []\n                    for j, command_arg in enumerate(get_command_args_fn(arg)):\n                        if j > 0:\n                            command_arg = repr(command_arg)\n                        command_args.append(command_arg)\n                    commands.append(\" \".join(command_args))\n\n                span.set_data(\n                    \"redis.commands\",\n                    {\"count\": len(self.command_stack), \"first_ten\": commands},\n                )\n\n            return old_execute(self, *args, **kwargs)\n\n    pipeline_cls.execute = sentry_patched_execute\n\n\ndef _get_redis_command_args(command):\n    # type: (Any) -> Sequence[Any]\n    return command[0]\n\n\ndef _parse_rediscluster_command(command):\n    # type: (Any) -> Sequence[Any]\n    return command.args\n\n\ndef _patch_rediscluster():\n    # type: () -> None\n    try:\n        import rediscluster  # type: ignore\n    except ImportError:\n        return\n\n    patch_redis_client(rediscluster.RedisCluster, is_cluster=True)\n\n    # up to v1.3.6, __version__ attribute is a tuple\n    # from v2.0.0, __version__ is a string and VERSION a tuple\n    version = getattr(rediscluster, \"VERSION\", rediscluster.__version__)\n\n    # StrictRedisCluster was introduced in v0.2.0 and removed in v2.0.0\n    # https://github.com/Grokzen/redis-py-cluster/blob/master/docs/release-notes.rst\n    if (0, 2, 0) < version < (2, 0, 0):\n        pipeline_cls = rediscluster.StrictClusterPipeline\n        patch_redis_client(rediscluster.StrictRedisCluster, is_cluster=True)\n    else:\n        pipeline_cls = rediscluster.ClusterPipeline\n\n    patch_redis_pipeline(pipeline_cls, True, _parse_rediscluster_command)\n\n\nclass RedisIntegration(Integration):\n    identifier = \"redis\"\n\n    @staticmethod\n    def setup_once():\n        # type: () -> None\n        try:\n            import redis\n        except ImportError:\n            raise DidNotEnable(\"Redis client not installed\")\n\n        patch_redis_client(redis.StrictRedis, is_cluster=False)\n        patch_redis_pipeline(redis.client.Pipeline, False, _get_redis_command_args)\n        try:\n            strict_pipeline = redis.client.StrictPipeline  # type: ignore\n        except AttributeError:\n            pass\n        else:\n            patch_redis_pipeline(strict_pipeline, False, _get_redis_command_args)\n\n        try:\n            import rb.clients  # type: ignore\n        except ImportError:\n            pass\n        else:\n            patch_redis_client(rb.clients.FanoutClient, is_cluster=False)\n            patch_redis_client(rb.clients.MappingClient, is_cluster=False)\n            patch_redis_client(rb.clients.RoutingClient, is_cluster=False)\n\n        try:\n            _patch_rediscluster()\n        except Exception:\n            logger.exception(\"Error occurred while patching `rediscluster` library\")\n\n\ndef patch_redis_client(cls, is_cluster):\n    # type: (Any, bool) -> None\n    \"\"\"\n    This function can be used to instrument custom redis client classes or\n    subclasses.\n    \"\"\"\n    old_execute_command = cls.execute_command\n\n    def sentry_patched_execute_command(self, name, *args, **kwargs):\n        # type: (Any, str, *Any, **Any) -> Any\n        hub = Hub.current\n\n        if hub.get_integration(RedisIntegration) is None:\n            return old_execute_command(self, name, *args, **kwargs)\n\n        description = name\n\n        with capture_internal_exceptions():\n            description_parts = [name]\n            for i, arg in enumerate(args):\n                if i > _MAX_NUM_ARGS:\n                    break\n\n                description_parts.append(repr(arg))\n\n            description = \" \".join(description_parts)\n\n        with hub.start_span(op=\"redis\", description=description) as span:\n            span.set_tag(\"redis.is_cluster\", is_cluster)\n            if name:\n                span.set_tag(\"redis.command\", name)\n\n            if name and args:\n                name_low = name.lower()\n                if (name_low in _SINGLE_KEY_COMMANDS) or (\n                    name_low in _MULTI_KEY_COMMANDS and len(args) == 1\n                ):\n                    span.set_tag(\"redis.key\", args[0])\n\n            return old_execute_command(self, name, *args, **kwargs)\n\n    cls.execute_command = sentry_patched_execute_command\n", "path": "sentry_sdk/integrations/redis.py"}]}