Skip to content

Commit 5f23719

Browse files
[skip ci]
1 parent 119e251 commit 5f23719

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

sentry_sdk/integrations/asgi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ async def _run_asgi3(self, scope, receive, send):
147147

148148
async def _run_app(self, scope, receive, send, asgi_version):
149149
# type: (Any, Any, Any, Any, int) -> Any
150+
# breakpoint()
150151
is_recursive_asgi_middleware = _asgi_middleware_applied.get(False)
151152
is_lifespan = scope["type"] == "lifespan"
152153
if is_recursive_asgi_middleware or is_lifespan:

sentry_sdk/utils_py3.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from sentry_sdk.hub import Hub
2+
from functools import wraps
3+
4+
from sentry_sdk._types import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from collections.abc import Awaitable, Callable
8+
from typing import Optional
9+
from sentry_sdk.integrations import Integration
10+
11+
12+
def integration_patched_async(original_function, integration=None):
13+
# type: (Callable[..., Awaitable[object]], Optional[type[Integration]]) -> Callable[[Callable[..., Awaitable[object]]], object]
14+
def patcher(sentry_patched_function):
15+
# type: (Callable[..., Awaitable[object]]) -> Callable[..., object]
16+
@wraps(original_function)
17+
async def runner(*args, **kwargs):
18+
# type: (*object, **object) -> object
19+
breakpoint()
20+
print("i am the runner")
21+
if (
22+
integration is not None
23+
and Hub.current.get_integration(integration) is None
24+
):
25+
return await original_function(*args, **kwargs)
26+
27+
return await sentry_patched_function(*args, **kwargs)
28+
29+
return runner
30+
31+
return patcher

0 commit comments

Comments
 (0)