-
Notifications
You must be signed in to change notification settings - Fork 548
feat(profiling): Enable profiling for ASGI frameworks #1824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2c9d119
6fc0cf4
3fbab08
e153022
4fc45bf
4df65a7
5e55ce9
abd8dbb
4dd8b0a
a1842dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import asyncio | ||
import threading | ||
|
||
from sentry_sdk._types import MYPY | ||
from sentry_sdk.hub import Hub, _should_send_default_pii | ||
from sentry_sdk.integrations import DidNotEnable | ||
|
@@ -62,6 +65,26 @@ def patch_get_request_handler(): | |
|
||
def _sentry_get_request_handler(*args, **kwargs): | ||
# type: (*Any, **Any) -> Any | ||
dependant = kwargs.get("dependant") | ||
if ( | ||
dependant | ||
and dependant.call is not None | ||
and not asyncio.iscoroutinefunction(dependant.call) | ||
): | ||
old_call = dependant.call | ||
Zylphrex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def _sentry_call(*args, **kwargs): | ||
# type: (*Any, **Any) -> Any | ||
hub = Hub.current | ||
with hub.configure_scope() as sentry_scope: | ||
if sentry_scope.profile is not None: | ||
sentry_scope.profile.active_thread_id = ( | ||
threading.current_thread().ident | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
) | ||
return old_call(*args, **kwargs) | ||
|
||
dependant.call = _sentry_call | ||
|
||
old_app = old_get_request_handler(*args, **kwargs) | ||
|
||
async def _sentry_app(*args, **kwargs): | ||
|
Uh oh!
There was an error while loading. Please reload this page.