Skip to content

Commit

Permalink
Avoid import of pkg_resource with Starlette integration (#1836)
Browse files Browse the repository at this point in the history
By changing the order in the condition, we can avoid the call to
`_get_installed_modules` (which imports `pkg_resources`) when the
`mechanism_type` is set to `"starlette"`.

Co-authored-by: Anton Pirker <anton.pirker@sentry.io>
  • Loading branch information
mgu and antonpirker committed Jan 19, 2023
1 parent 3f38f79 commit f6af7a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/asgi.py
Expand Up @@ -109,7 +109,7 @@ def __init__(
)

asgi_middleware_while_using_starlette_or_fastapi = (
"starlette" in _get_installed_modules() and mechanism_type == "asgi"
mechanism_type == "asgi" and "starlette" in _get_installed_modules()
)
if asgi_middleware_while_using_starlette_or_fastapi:
logger.warning(
Expand Down

0 comments on commit f6af7a0

Please sign in to comment.