Skip to content

feat(profiling): Enable profiling for ASGI frameworks#1824

Merged
Zylphrex merged 10 commits intomasterfrom
txiao/feat/enable-profiling-for-asgi-frameworks
Jan 17, 2023
Merged

feat(profiling): Enable profiling for ASGI frameworks#1824
Zylphrex merged 10 commits intomasterfrom
txiao/feat/enable-profiling-for-asgi-frameworks

Conversation

@Zylphrex
Copy link
Copy Markdown
Member

@Zylphrex Zylphrex commented Jan 5, 2023

This enables profiling for ASGI frameworks. When running in ASGI sync views, the
transaction gets started in the main thread then the request is dispatched to a
handler thread. We want to set the handler thread as the active thread id to
ensure that profiles will show it on first render.

This enables profiling for ASGI frameworks. When running in ASGI sync views, the
transaction gets started in the main thread then the request is dispatched to a
handler thread. We want to set the handler thread as the active thread id to
ensure that profiles will show it on first render.
@Zylphrex Zylphrex force-pushed the txiao/feat/enable-profiling-for-asgi-frameworks branch from 4411f92 to 2c9d119 Compare January 5, 2023 21:51
@Zylphrex Zylphrex changed the title feat(profiling): Set active thread id for ASGI frameworks feat(profiling): Enable profiling for ASGI frameworks Jan 5, 2023
@Zylphrex Zylphrex marked this pull request as ready for review January 9, 2023 17:16
@Zylphrex Zylphrex requested review from a team and sl0thentr0py January 9, 2023 17:16
Zylphrex added a commit that referenced this pull request Jan 10, 2023
Following up to #1824 to set the active thread id for quart.
with hub.configure_scope() as sentry_scope:
if sentry_scope.profile is not None:
sentry_scope.profile.active_thread_id = (
threading.current_thread().ident
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because current_thread() can be a dummy object (see https://docs.python.org/3/library/threading.html#threading.current_thread) maybe it is saver to use threading.get_ident()?
(But if the dummy object also has a .ident my comment can be ignored)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_DummyThread inherits from Thread (source) and so both should have the ident property.

@Zylphrex Zylphrex merged commit 43ca991 into master Jan 17, 2023
@Zylphrex Zylphrex deleted the txiao/feat/enable-profiling-for-asgi-frameworks branch January 17, 2023 20:49
Zylphrex added a commit that referenced this pull request Jan 19, 2023
Following up to #1824 to set the active thread id for quart.
sl0thentr0py pushed a commit that referenced this pull request Mar 6, 2023
Following up to #1824 to set the active thread id for quart.
sl0thentr0py pushed a commit that referenced this pull request Mar 6, 2023
Following up to #1824 to set the active thread id for quart.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants