Title: KeyError: 'auto_session_tracking' in version 1.5.5 · Issue #1334 · getsentry/sentry-python · GitHub
Open Graph Title: KeyError: 'auto_session_tracking' in version 1.5.5 · Issue #1334 · getsentry/sentry-python
X Title: KeyError: 'auto_session_tracking' in version 1.5.5 · Issue #1334 · getsentry/sentry-python
Description: Environment Python 3.10.2 sentry-sdk=1.5.5 fastapi==0.73.0 All packages aiojobs==1.0.0 aiomysql==0.0.22 anyio==3.5.0 asgiref==3.5.0 async-timeout==4.0.2 attrs==21.4.0 Brotli==1.0.9 cached-property==1.5.2 certifi==2021.10.8 charset-normal...
Open Graph Description: Environment Python 3.10.2 sentry-sdk=1.5.5 fastapi==0.73.0 All packages aiojobs==1.0.0 aiomysql==0.0.22 anyio==3.5.0 asgiref==3.5.0 async-timeout==4.0.2 attrs==21.4.0 Brotli==1.0.9 cached-property=...
X Description: Environment Python 3.10.2 sentry-sdk=1.5.5 fastapi==0.73.0 All packages aiojobs==1.0.0 aiomysql==0.0.22 anyio==3.5.0 asgiref==3.5.0 async-timeout==4.0.2 attrs==21.4.0 Brotli==1.0.9 cached-property=...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/1334
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"KeyError: 'auto_session_tracking' in version 1.5.5","articleBody":"### Environment\r\n\r\nPython 3.10.2\r\nsentry-sdk=**1.5.5**\r\nfastapi==0.73.0\r\n\r\n\u003cdetails>\u003csummary>All packages\u003c/summary>\u003cp>\r\n\r\naiojobs==1.0.0\r\naiomysql==0.0.22\r\nanyio==3.5.0\r\nasgiref==3.5.0\r\nasync-timeout==4.0.2\r\nattrs==21.4.0\r\nBrotli==1.0.9\r\ncached-property==1.5.2\r\ncertifi==2021.10.8\r\ncharset-normalizer==2.0.11\r\nclick==8.0.3\r\ncoverage==6.3.1\r\ndnspython==2.2.0\r\nemail-validator==1.1.3\r\nenvparse==0.2.0\r\nexecnet==1.9.0\r\nfastapi==0.73.0\r\nfastapi-utils==0.2.1\r\nfastnumbers==3.2.1\r\nfluent-logger==0.10.0\r\ngreenlet==1.1.2\r\nh11==0.12.0\r\nhttpcore==0.14.7\r\nhttpx==0.22.0\r\nidna==3.3\r\niniconfig==1.1.1\r\nisodate==0.6.1\r\njmespath==0.10.0\r\nlxml==4.7.1\r\nmotor==2.5.1\r\nmsgpack==1.0.3\r\nmysqlclient==2.1.0\r\nnatsort==8.1.0\r\npackaging==21.3\r\npep517==0.12.0\r\npip-tools==6.5.1\r\nplatformdirs==2.5.0\r\npluggy==1.0.0\r\npy==1.11.0\r\npydantic==1.9.0\r\npymongo==3.12.3\r\nPyMySQL==0.9.3\r\npyparsing==3.0.7\r\npytest==7.0.1\r\npytest-asyncio==0.18.1\r\npytest-cov==3.0.0\r\npytest-forked==1.4.0\r\npytest-xdist==2.5.0\r\npython-snappy==0.6.0\r\npytz==2021.3\r\nPyYAML==6.0\r\nrequests==2.27.1\r\nrequests-file==1.5.1\r\nrequests-toolbelt==0.9.1\r\nrfc3986==1.5.0\r\nsentry-sdk==1.5.5\r\nsix==1.16.0\r\nsniffio==1.2.0\r\nSQLAlchemy==1.4.31\r\nstarlette==0.17.1\r\ntomli==2.0.1\r\ntyping_extensions==4.0.1\r\nujson==5.1.0\r\nurllib3==1.26.8\r\nuvicorn==0.17.4\r\nuvloop==0.16.0\r\nzeep==4.1.0\r\nzstandard==0.17.0\r\n\u003c/p>\r\n\u003c/details>\r\n### Steps to Reproduce\r\n\r\n1. test_sentry.py\r\n```python\r\n# -*- codong: utf-8 -*-\r\nfrom fastapi import FastAPI\r\nfrom sentry_sdk.integrations.asgi import SentryAsgiMiddleware\r\nfrom starlette.testclient import TestClient\r\n\r\n\r\ndef test_sentry():\r\n app = FastAPI()\r\n\r\n @app.get(\"/\")\r\n async def index():\r\n return 'Ok'\r\n\r\n asgi_app = SentryAsgiMiddleware(app)\r\n\r\n with TestClient(app=asgi_app) as client:\r\n rsp = client.get('/')\r\n assert rsp.status_code == 200\r\n```\r\n2. pytest test_sentry\r\n3. test_sentry.py F [100%]\r\n### Expected Result\r\n\r\ntest_sentry Ok\r\n\r\n### Actual Result\r\n\r\nFAILED\r\n```python\r\n def is_auto_session_tracking_enabled(hub=None):\r\n # type: (Optional[sentry_sdk.Hub]) -> bool\r\n \"\"\"Utility function to find out if session tracking is enabled.\"\"\"\r\n if hub is None:\r\n hub = sentry_sdk.Hub.current\r\n should_track = hub.scope._force_auto_session_tracking\r\n if should_track is None:\r\n client_options = hub.client.options if hub.client else {}\r\n> should_track = client_options[\"auto_session_tracking\"]\r\nE KeyError: 'auto_session_tracking'\r\n```\r\n\r\n\u003cdetails>\u003csummary>pytest out\u003c/summary>\u003cp>\r\n\r\n```\r\ntest_sentry.py:6 (test_sentry)\r\ndef test_sentry():\r\n app = FastAPI()\r\n \r\n @app.get(\"/\")\r\n async def index():\r\n return 'Ok'\r\n \r\n asgi_app = SentryAsgiMiddleware(app)\r\n \r\n> with TestClient(app=asgi_app) as client:\r\n\r\ntests/test_sentry.py:16: \r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\n/home/tonal/.pyenv/versions/epool-delivery_calc/lib/python3.10/site-packages/starlette/testclient.py:524: in __enter__\r\n portal.call(self.wait_startup)\r\n/home/tonal/.pyenv/versions/epool-delivery_calc/lib/python3.10/site-packages/anyio/from_thread.py:240: in call\r\n return cast(T_Retval, self.start_task_soon(func, *args).result())\r\n/home/tonal/.pyenv/versions/3.10.2/lib/python3.10/concurrent/futures/_base.py:446: in result\r\n return self.__get_result()\r\n/home/tonal/.pyenv/versions/3.10.2/lib/python3.10/concurrent/futures/_base.py:391: in __get_result\r\n raise self._exception\r\n/home/tonal/.pyenv/versions/epool-delivery_calc/lib/python3.10/site-packages/anyio/from_thread.py:187: in _call_func\r\n retval = await retval\r\n/home/tonal/.pyenv/versions/epool-delivery_calc/lib/python3.10/site-packages/starlette/testclient.py:553: in wait_startup\r\n message = await receive()\r\n/home/tonal/.pyenv/versions/epool-delivery_calc/lib/python3.10/site-packages/starlette/testclient.py:550: in receive\r\n self.task.result()\r\n/home/tonal/.pyenv/versions/3.10.2/lib/python3.10/concurrent/futures/_base.py:439: in result\r\n return self.__get_result()\r\n/home/tonal/.pyenv/versions/3.10.2/lib/python3.10/concurrent/futures/_base.py:391: in __get_result\r\n raise self._exception\r\n/home/tonal/.pyenv/versions/epool-delivery_calc/lib/python3.10/site-packages/anyio/from_thread.py:187: in _call_func\r\n retval = await retval\r\n/home/tonal/.pyenv/versions/epool-delivery_calc/lib/python3.10/site-packages/starlette/testclient.py:540: in lifespan\r\n await self.app(scope, self.stream_receive.receive, self.stream_send.send)\r\n/home/tonal/.pyenv/versions/epool-delivery_calc/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py:107: in _run_asgi3\r\n return await self._run_app(scope, lambda: self.app(scope, receive, send))\r\n/home/tonal/.pyenv/versions/epool-delivery_calc/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py:123: in _run_app\r\n with auto_session_tracking(hub, session_mode=\"request\"):\r\n/home/tonal/.pyenv/versions/3.10.2/lib/python3.10/contextlib.py:135: in __enter__\r\n return next(self.gen)\r\n/home/tonal/.pyenv/versions/epool-delivery_calc/lib/python3.10/site-packages/sentry_sdk/sessions.py:39: in auto_session_tracking\r\n should_track = is_auto_session_tracking_enabled(hub)\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\n\r\nhub = \u003csentry_sdk.hub.Hub object at 0x7f20c74d6830>\r\n\r\n def is_auto_session_tracking_enabled(hub=None):\r\n # type: (Optional[sentry_sdk.Hub]) -> bool\r\n \"\"\"Utility function to find out if session tracking is enabled.\"\"\"\r\n if hub is None:\r\n hub = sentry_sdk.Hub.current\r\n should_track = hub.scope._force_auto_session_tracking\r\n if should_track is None:\r\n client_options = hub.client.options if hub.client else {}\r\n> should_track = client_options[\"auto_session_tracking\"]\r\nE KeyError: 'auto_session_tracking'\r\n```\r\n\u003c/p>\r\n\u003c/details>\r\n\r\nIn version sentry-sdk=**1.5.4** all work Ok","author":{"url":"https://github.com/tonal","@type":"Person","name":"tonal"},"datePublished":"2022-02-12T07:37:17Z","url":"https://github.com/getsentry/sentry-python/issues/1334"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:219f84ca-5ca5-e2e0-501a-4184035134e3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 89E6:3FF2FE:3087D2:436695:6B008A44 |
| html-safe-nonce | 5eda352fb9a1802fb8ae2db6d8ae14bdccc284675fd6acb6e99bb6d35a533f63 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OUU2OjNGRjJGRTozMDg3RDI6NDM2Njk1OjZCMDA4QTQ0IiwidmlzaXRvcl9pZCI6IjY2ODU0MTg4NzM1MjI1MjI2OTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e5dc02f2da07cc6e33cc325e0698d17e2e2181a780afbf3cec2f75cd97b49385 |
| hovercard-subject-tag | issue:1133676390 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/1334/issue_layout |
| twitter:image | https://opengraph.githubassets.com/84c121fe1512b037482c3af6b7c44b50cd487bd72de8fdf735510148f3b254a8/getsentry/sentry-python/issues/1334 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/84c121fe1512b037482c3af6b7c44b50cd487bd72de8fdf735510148f3b254a8/getsentry/sentry-python/issues/1334 |
| og:image:alt | Environment Python 3.10.2 sentry-sdk=1.5.5 fastapi==0.73.0 All packages aiojobs==1.0.0 aiomysql==0.0.22 anyio==3.5.0 asgiref==3.5.0 async-timeout==4.0.2 attrs==21.4.0 Brotli==1.0.9 cached-property=... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tonal |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4d3d8e50f02c1d7bf86d5acfa1d3bfe9366abd6528a6b429eb07a168429d2b61 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | db758f8e02b8257935fb03edf81a3e76eb3abd11 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width