Closed
Description
Offical spec https://asgi.readthedocs.io/en/latest/specs/lifespan.html
I'm using uvicorn and fastapi. I originally using encode/sentry-asgi and these days I found that there is a AsgiMiddleware in sentry-sdk. So i try to start using sentry_sdk.integrations.asgi.SentryAsgiMiddleware
But I got
INFO: ASGI 'lifespan' protocol appears unsupported.
I got this error in asyncio debug mode:
WARNING: Executing <Task pending coro=<Server.serve() running at C:\Users\Trim21\.venv\www\lib\site-packages\uvicorn\main.py:322> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x0000019878C3C468>()] created at C:\Users\Trim21\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py:391> cb=[_run_until_complete_cb() at C:\Users\Trim21\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py:153] created at C:\Users\Trim21\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py:558> took 1.265 seconds
ERROR: Exception in 'lifespan' protocol
Traceback (most recent call last):
File "C:\Users\Trim21\.venv\www\lib\site-packages\uvicorn\lifespan\on.py", line 44, in main
await app(scope, self.receive, self.send)
File "C:\Users\Trim21\.venv\www\lib\site-packages\starlette\applications.py", line 133, in __call__
await self.error_middleware(scope, receive, send)
File "C:\Users\Trim21\.venv\www\lib\site-packages\starlette\middleware\errors.py", line 142, in __call__
await self.app(scope, receive, send)
File "C:\Users\Trim21\.venv\www\lib\site-packages\starlette\middleware\base.py", line 21, in __call__
await self.app(scope, receive, send)
File "C:\Users\Trim21\.venv\www\lib\site-packages\starlette\middleware\base.py", line 21, in __call__
await self.app(scope, receive, send)
File ".\app\middlewares\log.py", line 12, in __call__
await self.app(scope, receive, send)
File "C:\Users\Trim21\.venv\www\lib\site-packages\sentry_sdk\integrations\asgi.py", line 71, in _run_app
span = Span.continue_from_headers(dict(scope["headers"]))
KeyError: 'headers'
It's not a http event so there is no headers
key in scope
env:
uvicorn version: 0.8.6
fastapi version: 0.38.1
python version: 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]
sentry-sdk version: 0.12.1
Metadata
Metadata
Assignees
Labels
No labels