Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
36844d6
Fixed patching of middlewares to fix the 'coroutine' error for non ex…
antonpirker Jul 28, 2022
9b8c99e
Only capture server errors
antonpirker Jul 29, 2022
f1ea0e0
Fixed form POST in FastApiIntegration.
antonpirker Aug 1, 2022
c8f2466
Fixed form uploads on starlette projects
antonpirker Aug 1, 2022
30fb5da
Fixed typing
antonpirker Aug 1, 2022
91f8dc5
Enable patching of middlewares again.
antonpirker Aug 2, 2022
2997550
Fixed typing
antonpirker Aug 2, 2022
773cf5c
Merge branch 'master' into antonpirker/1514-fastapi-bugs
antonpirker Aug 2, 2022
ed10d5e
Auto enable Starlette/FastAPI
antonpirker Aug 2, 2022
e4600fc
Merge branch 'master' into antonpirker/1514-fastapi-bugs
antonpirker Aug 3, 2022
8b85080
Merge branch 'master' into antonpirker/1514-fastapi-bugs
antonpirker Aug 4, 2022
b11f20b
Cleanup useless code
antonpirker Aug 4, 2022
7eebd53
Fixed error while handling 404 errors.
antonpirker Aug 4, 2022
423a221
Fix error during handling of form validation error.
antonpirker Aug 4, 2022
36ea140
Find the correct handler (for classes with parent classes
antonpirker Aug 4, 2022
1b6eb7a
Merge branch 'antonpirker/1514-fastapi-bugs' of github.com:getsentry/…
antonpirker Aug 4, 2022
0709979
Merge branch 'master' into antonpirker/1514-fastapi-bugs
antonpirker Aug 4, 2022
8176cb2
Fixed linting
antonpirker Aug 4, 2022
2552a61
Do not call starlette integration, because it needs to be set in the …
antonpirker Aug 4, 2022
35d4035
Auto enable Starlette/FastAPI
antonpirker Aug 2, 2022
73394b0
Merge branch 'antonpirker/1531-auto-enable-starlette-fastapi' of gith…
antonpirker Aug 5, 2022
cc4b9fc
Fail with a nice error message when ASGI middleware is used and Starl…
antonpirker Aug 5, 2022
c498960
Merge branch 'master' into antonpirker/1531-auto-enable-starlette-fas…
antonpirker Aug 5, 2022
22775e3
Merge branch 'master' into antonpirker/1531-auto-enable-starlette-fas…
antonpirker Aug 30, 2022
a41b1b4
Better check for using asgi middleware and starlette/fastapi integrat…
antonpirker Aug 30, 2022
33f9083
Merge branch 'antonpirker/1531-auto-enable-starlette-fastapi' of gith…
antonpirker Aug 30, 2022
7707a1a
Fixed FastAPI tests.
antonpirker Aug 31, 2022
0807dd1
Code formatting
antonpirker Aug 31, 2022
8f54505
Fixed starlette tests
antonpirker Aug 31, 2022
7e0108a
Deactivated ASGI tests because they have to be rewritten without Star…
antonpirker Aug 31, 2022
7381be5
Fixed test and made it easier to debug.
antonpirker Aug 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sentry_sdk/integrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def iter_default_integrations(with_auto_enabling_integrations):
_AUTO_ENABLING_INTEGRATIONS = (
"sentry_sdk.integrations.django.DjangoIntegration",
"sentry_sdk.integrations.flask.FlaskIntegration",
"sentry_sdk.integrations.starlette.StarletteIntegration",
"sentry_sdk.integrations.fastapi.FastApiIntegration",
"sentry_sdk.integrations.bottle.BottleIntegration",
"sentry_sdk.integrations.falcon.FalconIntegration",
"sentry_sdk.integrations.sanic.SanicIntegration",
Expand Down
12 changes: 11 additions & 1 deletion sentry_sdk/integrations/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from sentry_sdk._types import MYPY
from sentry_sdk.hub import Hub, _should_send_default_pii
from sentry_sdk.integrations._wsgi_common import _filter_headers
from sentry_sdk.integrations.modules import _get_installed_modules
from sentry_sdk.sessions import auto_session_tracking
from sentry_sdk.tracing import (
SOURCE_FOR_STYLE,
Expand Down Expand Up @@ -91,7 +92,6 @@ def __init__(

:param unsafe_context_data: Disable errors when a proper contextvars installation could not be found. We do not recommend changing this from the default.
"""

if not unsafe_context_data and not HAS_REAL_CONTEXTVARS:
# We better have contextvars or we're going to leak state between
# requests.
Expand All @@ -108,6 +108,16 @@ def __init__(
self.mechanism_type = mechanism_type
self.app = app

asgi_middleware_while_using_starlette_or_fastapi = (
"starlette" in _get_installed_modules() and self.mechanism_type == "asgi"
)
if asgi_middleware_while_using_starlette_or_fastapi:
raise RuntimeError(
"The Sentry Python SDK can now automatically support ASGI frameworks like Starlette and FastAPI. "
"Please remove 'SentryAsgiMiddleware' from your project. "
"See https://docs.sentry.io/platforms/python/guides/asgi/ for more information."
)

if _looks_like_asgi3(app):
self.__call__ = self._run_asgi3 # type: Callable[..., Any]
else:
Expand Down
3 changes: 0 additions & 3 deletions tests/integrations/asgi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
import pytest

pytest.importorskip("starlette")
Loading