Skip to content

Commit 5e669ff

Browse files
committed
Auto-enable Anthropic integration + gate imports
1 parent 41aa99b commit 5e669ff

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

sentry_sdk/integrations/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def iter_default_integrations(with_auto_enabling_integrations):
6969

7070
_AUTO_ENABLING_INTEGRATIONS = [
7171
"sentry_sdk.integrations.aiohttp.AioHttpIntegration",
72+
"sentry_sdk.integrations.anthropic.AnthropicIntegration",
7273
"sentry_sdk.integrations.ariadne.AriadneIntegration",
7374
"sentry_sdk.integrations.arq.ArqIntegration",
7475
"sentry_sdk.integrations.asyncpg.AsyncPGIntegration",

sentry_sdk/integrations/anthropic.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@
1212
package_version,
1313
)
1414

15-
from anthropic.resources import Messages
16-
1715
from typing import TYPE_CHECKING
1816

17+
try:
18+
from anthropic.resources import Messages
19+
20+
if TYPE_CHECKING:
21+
from anthropic.types import MessageStreamEvent
22+
except ImportError:
23+
raise DidNotEnable("Anthropic not installed")
24+
25+
1926
if TYPE_CHECKING:
2027
from typing import Any, Iterator
21-
from anthropic.types import MessageStreamEvent
2228
from sentry_sdk.tracing import Span
2329

2430

0 commit comments

Comments
 (0)