question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi folks. I’m considering tackling an ASGI integration, that’d bring support to Starlette, Responder, Quart.

Because we’d need to monkey-path a generic application __call__ method, rather than a known class, you’d need to pass the app instance to the integration instantiation.

import sentry_sdk
from sentry_sdk.integrations.asgi import ASGIIntegration

app = Starlette()

sentry_sdk.init(
    dsn="https://<key>@sentry.io/<project>",
    integrations=[ASGIIntegration(app)]
)

Alternatively, you could design a generic ASGI implementation, and just have very light individual framework-specific integrations that just plugged that into starlette’s Starlette.__call__, responder’s API.__call__, etc…

When handled properly ASGI exceptions are still propagated out of the stack, even when a technical 500 page has been sent by the framework, so I think that along with logging there’s plenty of generic context that can be captured here.

I guess my initial questions would be:

  • Should I be thinking of this in terms of a third-party library, or looking to build it in for the official sentry-python package as an integration?
  • What important context am I likely to be missing out on by working at this level, rather than at a framework specific level? (It’s possible that we might get some loose patterns around where things like user state or routed endpoint should get kept in the ASGI scope dictionary, so it’s feasible we might be able to capture some of that, as well as the basic request info)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
untitakercommented, Jul 16, 2019

0.10.2 adds an ASGI middleware: https://docs.sentry.io/platforms/python/asgi/

1reaction
untitakercommented, Nov 2, 2018

Wrt hubs see #147, you need a new hub in asyncio for now

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASGI Documentation — ASGI 3.0 documentation
ASGI (Asynchronous Server Gateway Interface) is a spiritual successor to WSGI, intended to provide a standard interface between async-capable Python web ...
Read more >
A curated list of awesome ASGI servers, frameworks ... - GitHub
Supports HTTP and WebSockets with Django integration, and any protocol with ASGI-native code. Django - The web framework for perfectionists with deadlines. Has ......
Read more >
ASGI explained: The future of Python web development
Unlike WSGI, ASGI allows multiple, asynchronous events per application. Plus, ASGI supports both sync and async apps. You can migrate your old, ...
Read more >
Asynchronous Server Gateway Interface - Wikipedia
The Asynchronous Server Gateway Interface (ASGI) is a calling convention for web servers to forward requests to asynchronous-capable Python programming ...
Read more >
How to deploy with ASGI - Django documentation
As well as WSGI, Django also supports deploying on ASGI, the emerging Python standard for asynchronous web servers and applications.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found