Skip to content

Commit

Permalink
Use get_distribution consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
xrmx committed Jul 31, 2024
1 parent 5febb55 commit 832475f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ def client_response_hook(span: Span, scope: dict[str, Any], message: dict[str, A
---
"""
import logging
from importlib.util import find_spec
from typing import Collection

import fastapi
Expand Down Expand Up @@ -294,8 +293,12 @@ def instrumentation_dependencies(self) -> Collection[str]:
except Exception: # pylint: disable=broad-exception-caught
pass

if find_spec("fastapi") is not None:
try:
get_distribution("fastapi")
return (_fastapi,)
except Exception: # pylint: disable=broad-exception-caught
pass

# If neither is installed, return both as potential dependencies
return _instruments

Expand Down

0 comments on commit 832475f

Please sign in to comment.