diff --git a/sentry_sdk/integrations/__init__.py b/sentry_sdk/integrations/__init__.py index fffd573491..a53ad288be 100644 --- a/sentry_sdk/integrations/__init__.py +++ b/sentry_sdk/integrations/__init__.py @@ -69,6 +69,7 @@ def iter_default_integrations(with_auto_enabling_integrations): _AUTO_ENABLING_INTEGRATIONS = [ "sentry_sdk.integrations.aiohttp.AioHttpIntegration", + "sentry_sdk.integrations.anthropic.AnthropicIntegration", "sentry_sdk.integrations.ariadne.AriadneIntegration", "sentry_sdk.integrations.arq.ArqIntegration", "sentry_sdk.integrations.asyncpg.AsyncPGIntegration", diff --git a/sentry_sdk/integrations/anthropic.py b/sentry_sdk/integrations/anthropic.py index 9d43093ac4..04583e38ea 100644 --- a/sentry_sdk/integrations/anthropic.py +++ b/sentry_sdk/integrations/anthropic.py @@ -12,13 +12,19 @@ package_version, ) -from anthropic.resources import Messages - from typing import TYPE_CHECKING +try: + from anthropic.resources import Messages + + if TYPE_CHECKING: + from anthropic.types import MessageStreamEvent +except ImportError: + raise DidNotEnable("Anthropic not installed") + + if TYPE_CHECKING: from typing import Any, Iterator - from anthropic.types import MessageStreamEvent from sentry_sdk.tracing import Span