Datasets:

Modalities:
Tabular
Text
Formats:
parquet
Size:
< 1K
ArXiv:
DOI:
Libraries:
Datasets
pandas
galtimur's picture
test data add
d822266
raw
history blame
15.3 kB
{"head_branch": "m.redis-cluster", "contributor": "md384", "sha_fail": "5c99ddda3d9a3b351827a83e560d416970559c90", "sha_success": "c868892b2710c3698681d3922a2991a11c380cdf", "language": "Python", "repo_owner": "getsentry", "repo_name": "sentry-python", "workflow_name": "CI", "workflow_filename": "ci.yml", "workflow_path": ".github/workflows/ci.yml", "workflow": "name: CI\n\non:\n push:\n branches:\n - master\n - release/**\n\n pull_request:\n\npermissions:\n contents: read\n\nenv:\n BUILD_CACHE_KEY: ${{ github.sha }}\n CACHED_BUILD_PATHS: |\n ${{ github.workspace }}/dist-serverless\n\njobs:\n lint:\n name: Lint Sources\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.12\n\n - run: |\n pip install tox\n tox -e linters\n\n check-ci-config:\n name: Check CI config\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.12\n\n - run: |\n pip install jinja2\n python scripts/split-tox-gh-actions/split-tox-gh-actions.py --fail-on-changes\n\n build_lambda_layer:\n name: Build Package\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.12\n - name: Setup build cache\n uses: actions/cache@v3\n id: build_cache\n with:\n path: ${{ env.CACHED_BUILD_PATHS }}\n key: ${{ env.BUILD_CACHE_KEY }}\n - name: Build Packages\n run: |\n echo \"Creating directory containing Python SDK Lambda Layer\"\n pip install virtualenv\n # This will also trigger \"make dist\" that creates the Python packages\n make aws-lambda-layer\n - name: Upload Python Packages\n uses: actions/upload-artifact@v3\n with:\n name: ${{ github.sha }}\n path: |\n dist/*\n\n docs:\n name: Build SDK API Doc\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.12\n\n - run: |\n pip install virtualenv\n make apidocs\n cd docs/_build && zip -r gh-pages ./\n\n - uses: actions/[email protected]\n with:\n name: ${{ github.sha }}\n path: docs/_build/gh-pages.zip\n", "logs": "Downloading cachetools-5.3.2-py3-none-any.whl (9.3 kB)\nDownloading chardet-5.2.0-py3-none-any.whl (199 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 199.4/199.4 kB 32.7 MB/s eta 0:00:00\nDownloading filelock-3.13.1-py3-none-any.whl (11 kB)\nDownloading packaging-23.2-py3-none-any.whl (53 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 53.0/53.0 kB 15.4 MB/s eta 0:00:00\nDownloading platformdirs-4.0.0-py3-none-any.whl (17 kB)\nDownloading pluggy-1.3.0-py3-none-any.whl (18 kB)\nDownloading pyproject_api-1.6.1-py3-none-any.whl (12 kB)\nDownloading virtualenv-20.24.7-py3-none-any.whl (3.8 MB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 3.8/3.8 MB 110.2 MB/s eta 0:00:00\nDownloading distlib-0.3.7-py2.py3-none-any.whl (468 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 468.9/468.9 kB 77.5 MB/s eta 0:00:00\nInstalling collected packages: distlib, pluggy, platformdirs, packaging, filelock, colorama, chardet, cachetools, virtualenv, pyproject-api, tox\nSuccessfully installed cachetools-5.3.2 chardet-5.2.0 colorama-0.4.6 distlib-0.3.7 filelock-3.13.1 packaging-23.2 platformdirs-4.0.0 pluggy-1.3.0 pyproject-api-1.6.1 tox-4.11.4 virtualenv-20.24.7\n\n[notice] A new release of pip is available: 23.2.1 -> 23.3.1\n[notice] To update, run: pip install --upgrade pip\nlinters: install_deps> python -I -m pip install 'werkzeug<2.3.0' -r test-requirements.txt -r linter-requirements.txt\n.pkg: install_requires> python -I -m pip install 'setuptools>=40.8.0' wheel\n.pkg: _optional_hooks> python /opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\n.pkg: get_requires_for_build_editable> python /opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\n.pkg: install_requires_for_build_editable> python -I -m pip install wheel\n.pkg: freeze> python -m pip freeze --all\n.pkg: pip==23.3.1,setuptools==69.0.2,wheel==0.42.0\n.pkg: build_editable> python /opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\nlinters: install_package_deps> python -I -m pip install certifi 'urllib3>=1.25.7; python_version <= \"3.4\"' 'urllib3>=1.26.11; python_version >= \"3.6\"' 'urllib3>=1.26.9; python_version == \"3.5\"'\nlinters: install_package> python -I -m pip install --force-reinstall --no-deps /home/runner/work/sentry-python/sentry-python/.tox/.tmp/package/1/sentry_sdk-1.38.0-0.editable-py2.py3-none-any.whl\nlinters: freeze> python -m pip freeze --all\nlinters: asttokens==2.4.1,attrs==23.1.0,black==23.11.0,certifi==2023.11.17,cffi==1.16.0,cfgv==3.4.0,charset-normalizer==3.3.2,click==8.1.7,colorama==0.4.6,coverage==7.3.2,cryptography==41.0.7,decorator==5.1.1,distlib==0.3.7,dnspython==2.4.2,docopt==0.6.2,executing==1.2.0,filelock==3.13.1,flake8==5.0.4,flake8-bugbear==23.3.12,identify==2.5.32,idna==3.6,iniconfig==2.0.0,ipdb==0.13.13,ipython==8.18.1,jedi==0.19.1,jsonschema==3.2.0,loguru==0.7.2,MarkupSafe==2.1.3,matplotlib-inline==0.1.6,mccabe==0.7.0,mypy==1.7.1,mypy-extensions==1.0.0,nodeenv==1.8.0,packaging==23.2,parso==0.8.3,pathspec==0.11.2,pep8-naming==0.13.3,pexpect==4.9.0,pip==23.3.1,platformdirs==4.0.0,pluggy==0.13.1,pre-commit==3.5.0,prompt-toolkit==3.0.41,ptyprocess==0.7.0,pure-eval==0.2.2,py==1.11.0,pycodestyle==2.9.1,pycparser==2.21,pyflakes==2.5.0,Pygments==2.17.2,pymongo==4.6.1,pyrsistent==0.16.0,PySocks==1.7.1,pytest==7.4.3,pytest-cov==2.8.1,pytest-forked==1.4.0,pytest-localserver==0.5.1,pytest-watch==4.2.0,PyYAML==6.0.1,requests==2.31.0,responses==0.24.1,sentry-sdk @ file:///home/runner/work/sentry-python/sentry-python/.tox/.tmp/package/1/sentry_sdk-1.38.0-0.editable-py2.py3-none-any.whl#sha256=0600ca84a4e5a0d0bd5f3f907f2806001272fb2955a950dd53ebd77aa23ee3bd,setuptools==69.0.2,six==1.16.0,stack-data==0.6.3,toml==0.10.2,tox==3.7.0,traitlets==5.14.0,types-certifi==2021.10.8.3,types-protobuf==4.24.0.4,types-pyOpenSSL==23.3.0.0,types-redis==4.6.0.11,types-setuptools==69.0.0.0,typing_extensions==4.8.0,urllib3==2.1.0,virtualenv==20.24.7,watchdog==3.0.0,wcwidth==0.2.12,Werkzeug==2.2.3\nlinters: commands[0]> flake8 tests sentry_sdk\nlinters: commands[1]> black --check tests sentry_sdk\nAll done! \u2728 \ud83c\udf70 \u2728\n274 files would be left unchanged.\nlinters: commands[2]> mypy sentry_sdk\nsentry_sdk/integrations/redis/__init__.py:143: error: Missing type parameters for generic type \"Redis\" [type-arg]\nsentry_sdk/integrations/redis/__init__.py:151: error: Missing type parameters for generic type \"RedisCluster\" [type-arg]\nsentry_sdk/integrations/redis/__init__.py:160: error: Missing type parameters for generic type \"RedisCluster\" [type-arg]\nsentry_sdk/integrations/redis/__init__.py:167: error: Missing type parameters for generic type \"ClusterPipeline\" [type-arg]\nsentry_sdk/integrations/redis/__init__.py:169: error: \"ClusterPipeline[Any]\" has no attribute \"_client\" [attr-defined]\nsentry_sdk/integrations/redis/asyncio.py:24: error: \"type\" has no attribute \"execute\" [attr-defined]\nsentry_sdk/integrations/redis/asyncio.py:48: error: \"type\" has no attribute \"execute\" [attr-defined]\nsentry_sdk/integrations/redis/asyncio.py:53: error: \"type\" has no attribute \"execute_command\" [attr-defined]\nsentry_sdk/integrations/redis/asyncio.py:70: error: \"type\" has no attribute \"execute_command\" [attr-defined]\nFound 9 errors in 2 files (checked 113 source files)\nlinters: exit 1 (9.18 seconds) /home/runner/work/sentry-python/sentry-python> mypy sentry_sdk pid=2111\n.pkg: _exit> python /opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\n linters: FAIL code 1 (48.73=setup[30.06]+cmd[4.06,5.42,9.18] seconds)\n evaluation failed :( (51.86 seconds)\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/sentry_sdk/integrations/redis/__init__.py b/sentry_sdk/integrations/redis/__init__.py\nindex 2e4e43a5..adb3380e 100644\n--- a/sentry_sdk/integrations/redis/__init__.py\n+++ b/sentry_sdk/integrations/redis/__init__.py\n@@ -141,7 +141,7 @@ def _set_db_data_on_span(span, connection_params):\n \n \n def _set_db_data(span, redis_instance):\n- # type: (Span, Redis) -> None\n+ # type: (Span, Redis[Any]) -> None\n try:\n _set_db_data_on_span(span, redis_instance.connection_pool.connection_kwargs)\n except AttributeError:\n@@ -149,7 +149,7 @@ def _set_db_data(span, redis_instance):\n \n \n def _set_cluster_db_data(span, redis_cluster_instance):\n- # type: (Span, RedisCluster) -> None\n+ # type: (Span, RedisCluster[Any]) -> None\n default_node = redis_cluster_instance.get_default_node()\n if default_node is not None:\n _set_db_data_on_span(\n@@ -158,15 +158,20 @@ def _set_cluster_db_data(span, redis_cluster_instance):\n \n \n def _set_async_cluster_db_data(span, async_redis_cluster_instance):\n- # type: (Span, AsyncRedisCluster) -> None\n+ # type: (Span, AsyncRedisCluster[Any]) -> None\n default_node = async_redis_cluster_instance.get_default_node()\n if default_node is not None and default_node.connection_kwargs is not None:\n _set_db_data_on_span(span, default_node.connection_kwargs)\n \n \n def _set_async_cluster_pipeline_db_data(span, async_redis_cluster_pipeline_instance):\n- # type: (Span, AsyncClusterPipeline) -> None\n- _set_async_cluster_db_data(span, async_redis_cluster_pipeline_instance._client)\n+ # type: (Span, AsyncClusterPipeline[Any]) -> None\n+ _set_async_cluster_db_data(\n+ span,\n+ # the AsyncClusterPipeline has always had a `_client` attr but it is private so potentially problematic and mypy\n+ # does not recognize it - see https://github.com/redis/redis-py/blame/v5.0.0/redis/asyncio/cluster.py#L1386\n+ async_redis_cluster_pipeline_instance._client, # type: ignore[attr-defined]\n+ )\n \n \n def patch_redis_pipeline(pipeline_cls, is_cluster, get_command_args_fn, set_db_data_fn):\ndiff --git a/sentry_sdk/integrations/redis/asyncio.py b/sentry_sdk/integrations/redis/asyncio.py\nindex 8da323be..09fad342 100644\n--- a/sentry_sdk/integrations/redis/asyncio.py\n+++ b/sentry_sdk/integrations/redis/asyncio.py\n@@ -14,13 +14,15 @@ from sentry_sdk.utils import capture_internal_exceptions\n \n if TYPE_CHECKING:\n from collections.abc import Callable\n- from typing import Any\n+ from typing import Any, Union\n+ from redis.asyncio.client import Pipeline, StrictRedis\n+ from redis.asyncio.cluster import ClusterPipeline, RedisCluster\n \n \n def patch_redis_async_pipeline(\n pipeline_cls, is_cluster, get_command_args_fn, set_db_data_fn\n ):\n- # type: (type, bool, Any, Callable[[Span, Any], None]) -> None\n+ # type: (Union[type[Pipeline[Any]], type[ClusterPipeline[Any]]], bool, Any, Callable[[Span, Any], None]) -> None\n old_execute = pipeline_cls.execute\n \n async def _sentry_execute(self, *args, **kwargs):\n@@ -45,11 +47,11 @@ def patch_redis_async_pipeline(\n \n return await old_execute(self, *args, **kwargs)\n \n- pipeline_cls.execute = _sentry_execute\n+ pipeline_cls.execute = _sentry_execute # type: ignore[method-assign]\n \n \n def patch_redis_async_client(cls, is_cluster, set_db_data_fn):\n- # type: (type, bool, Callable[[Span, Any], None]) -> None\n+ # type: (Union[type[StrictRedis[Any]], type[RedisCluster[Any]]], bool, Callable[[Span, Any], None]) -> None\n old_execute_command = cls.execute_command\n \n async def _sentry_execute_command(self, name, *args, **kwargs):\n@@ -67,4 +69,4 @@ def patch_redis_async_client(cls, is_cluster, set_db_data_fn):\n \n return await old_execute_command(self, name, *args, **kwargs)\n \n- cls.execute_command = _sentry_execute_command\n+ cls.execute_command = _sentry_execute_command # type: ignore[method-assign]\ndiff --git a/tests/integrations/redis/cluster/test_redis_cluster.py b/tests/integrations/redis/cluster/test_redis_cluster.py\nindex 95e6627a..d04bd7ba 100644\n--- a/tests/integrations/redis/cluster/test_redis_cluster.py\n+++ b/tests/integrations/redis/cluster/test_redis_cluster.py\n@@ -17,7 +17,7 @@ def monkeypatch_rediscluster_class(reset_integrations):\n \"localhost\", 6379\n )\n pipeline_cls.execute = lambda *_, **__: None\n- redis.RedisCluster.execute_command = lambda *_, **__: None\n+ redis.RedisCluster.execute_command = lambda *_, **__: []\n \n \n def test_rediscluster_breadcrumb(sentry_init, capture_events):\n@@ -29,7 +29,15 @@ def test_rediscluster_breadcrumb(sentry_init, capture_events):\n capture_message(\"hi\")\n \n (event,) = events\n- (crumb,) = event[\"breadcrumbs\"][\"values\"]\n+ crumbs = event[\"breadcrumbs\"][\"values\"]\n+\n+ # on initializing a RedisCluster, a COMMAND call is made - this is not important for the test\n+ # but must be accounted for\n+ assert len(crumbs) <= 2\n+ if len(crumbs) == 2:\n+ assert event[\"breadcrumbs\"][\"values\"][0][\"message\"] == \"COMMAND\"\n+\n+ crumb = event[\"breadcrumbs\"][\"values\"][-1]\n \n assert crumb == {\n \"category\": \"redis\",\n@@ -65,7 +73,15 @@ def test_rediscluster_basic(sentry_init, capture_events, send_default_pii, descr\n rc.set(\"bar\", 1)\n \n (event,) = events\n- (span,) = event[\"spans\"]\n+ spans = event[\"spans\"]\n+\n+ # on initializing a RedisCluster, a COMMAND call is made - this is not important for the test\n+ # but must be accounted for\n+ assert len(spans) <= 2\n+ if len(spans) == 2:\n+ assert event[\"spans\"][0][\"description\"] == \"COMMAND\"\n+\n+ span = event[\"spans\"][-1]\n assert span[\"op\"] == \"db.redis\"\n assert span[\"description\"] == description\n assert span[\"data\"] == {\n"}