Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions sentry_sdk/integrations/anthropic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import sys
import warnings
from collections.abc import Iterable
from functools import wraps
from typing import TYPE_CHECKING, cast
Expand Down Expand Up @@ -222,8 +223,20 @@ class AnthropicIntegration(Integration):
identifier = "anthropic"
origin = f"auto.ai.{identifier}"

def __init__(self: "AnthropicIntegration", include_prompts: bool = True) -> None:
self.include_prompts = include_prompts
def __init__(
self: "AnthropicIntegration", include_prompts: "Optional[bool]" = None
) -> None:
if include_prompts is not None:
warnings.warn(
"`AnthropicIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
"To disable capture of GenAI attributes, pass "
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
"to `sentry_sdk.init`.",
DeprecationWarning,
stacklevel=2,
)

self.include_prompts = True if include_prompts is None else include_prompts

@staticmethod
def setup_once() -> None:
Expand Down
19 changes: 16 additions & 3 deletions sentry_sdk/integrations/cohere.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import warnings
from functools import wraps
from typing import TYPE_CHECKING

Expand All @@ -10,7 +11,7 @@
from sentry_sdk.tracing_utils import has_span_streaming_enabled

if TYPE_CHECKING:
from typing import Any, Callable, Iterator, Union
from typing import Any, Callable, Iterator, Optional, Union

from sentry_sdk.tracing import Span

Expand Down Expand Up @@ -78,8 +79,20 @@
identifier = "cohere"
origin = f"auto.ai.{identifier}"

def __init__(self: "CohereIntegration", include_prompts: bool = True) -> None:
self.include_prompts = include_prompts
def __init__(
self: "CohereIntegration", include_prompts: "Optional[bool]" = True
) -> None:
if include_prompts is not None:
Comment thread
alexander-alderman-webb marked this conversation as resolved.
Resolved
warnings.warn(
"`CohereIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
"To disable capture of GenAI attributes, pass "
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
"to `sentry_sdk.init`.",
DeprecationWarning,
stacklevel=2,
)

self.include_prompts = True if include_prompts is None else include_prompts

Check warning on line 95 in sentry_sdk/integrations/cohere.py

View check run for this annotation

@sentry/warden / warden: find-bugs

Default include_prompts=True triggers a deprecation warning for LangchainIntegration

`LangchainIntegration.__init__` defaults `include_prompts` to `True` but warns whenever it is non-`None`, so constructing it without passing the deprecated argument triggers the warning. Use `None` as the parameter default and retain the existing assignment so the runtime default remains `True`.

@staticmethod
def setup_once() -> None:
Expand Down
18 changes: 16 additions & 2 deletions sentry_sdk/integrations/google_genai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import warnings
from functools import wraps
from typing import (
Any,
AsyncIterator,
Callable,
Iterator,
List,
Optional,
)

import sentry_sdk
Expand Down Expand Up @@ -41,8 +43,20 @@ class GoogleGenAIIntegration(Integration):
identifier = IDENTIFIER
origin = ORIGIN

def __init__(self: "GoogleGenAIIntegration", include_prompts: bool = True) -> None:
self.include_prompts = include_prompts
def __init__(
self: "GoogleGenAIIntegration", include_prompts: "Optional[bool]" = None
) -> None:
if include_prompts is not None:
warnings.warn(
"`GoogleGenAIIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
"To disable capture of GenAI attributes, pass "
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
"to `sentry_sdk.init`.",
DeprecationWarning,
stacklevel=2,
)

self.include_prompts = True if include_prompts is None else include_prompts

@staticmethod
def setup_once() -> None:
Expand Down
17 changes: 14 additions & 3 deletions sentry_sdk/integrations/huggingface_hub.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import inspect
import sys
import warnings
from functools import wraps
from typing import TYPE_CHECKING, cast

Expand All @@ -23,7 +24,7 @@
)

if TYPE_CHECKING:
from typing import Any, Callable, Iterable, Union
from typing import Any, Callable, Iterable, Optional, Union

from huggingface_hub import (
ChatCompletionStreamOutput,
Expand All @@ -42,9 +43,19 @@ class HuggingfaceHubIntegration(Integration):
origin = f"auto.ai.{identifier}"

def __init__(
self: "HuggingfaceHubIntegration", include_prompts: bool = True
self: "HuggingfaceHubIntegration", include_prompts: "Optional[bool]" = None
) -> None:
self.include_prompts = include_prompts
if include_prompts is not None:
warnings.warn(
"`HuggingfaceHubIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
"To disable capture of GenAI attributes, pass "
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
"to `sentry_sdk.init`.",
DeprecationWarning,
stacklevel=2,
)

self.include_prompts = True if include_prompts is None else include_prompts

@staticmethod
def setup_once() -> None:
Expand Down
14 changes: 12 additions & 2 deletions sentry_sdk/integrations/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,20 @@

def __init__(
self: "LangchainIntegration",
include_prompts: bool = True,
include_prompts: "Optional[bool]" = True,
max_spans: "Optional[int]" = None,
) -> None:
self.include_prompts = include_prompts
if include_prompts is not None:
warnings.warn(
"`LangchainIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
"To disable capture of GenAI attributes, pass "
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
"to `sentry_sdk.init`.",
DeprecationWarning,
stacklevel=2,
)

self.include_prompts = True if include_prompts is None else include_prompts

Check warning on line 250 in sentry_sdk/integrations/langchain.py

View check run for this annotation

@sentry/warden / warden: code-review

Default include_prompts=True always warns in CohereIntegration

Default `include_prompts` to `None` in `CohereIntegration` so the deprecation warning only fires when the argument is explicitly passed. With `= True`, auto-enabling Cohere constructs the integration without arguments and still emits the warning.
Comment thread
alexander-alderman-webb marked this conversation as resolved.
Resolved
self.max_spans = max_spans

if max_spans is not None:
Expand Down
17 changes: 15 additions & 2 deletions sentry_sdk/integrations/langgraph.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from functools import wraps
from typing import Any, Callable, List, Optional

Expand Down Expand Up @@ -33,8 +34,20 @@ class LanggraphIntegration(Integration):
identifier = "langgraph"
origin = f"auto.ai.{identifier}"

def __init__(self: "LanggraphIntegration", include_prompts: bool = True) -> None:
self.include_prompts = include_prompts
def __init__(
self: "LanggraphIntegration", include_prompts: "Optional[bool]" = None
) -> None:
if include_prompts is not None:
warnings.warn(
"`LanggraphIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
"To disable capture of GenAI attributes, pass "
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
"to `sentry_sdk.init`.",
DeprecationWarning,
stacklevel=2,
)

self.include_prompts = True if include_prompts is None else include_prompts

@staticmethod
def setup_once() -> None:
Expand Down
19 changes: 16 additions & 3 deletions sentry_sdk/integrations/litellm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
import warnings
from typing import TYPE_CHECKING

import sentry_sdk
Expand All @@ -22,7 +23,7 @@

if TYPE_CHECKING:
from datetime import datetime
from typing import Any, Dict, List
from typing import Any, Dict, List, Optional

try:
import litellm # type: ignore[import-not-found]
Expand Down Expand Up @@ -364,8 +365,20 @@ class LiteLLMIntegration(Integration):
identifier = "litellm"
origin = f"auto.ai.{identifier}"

def __init__(self: "LiteLLMIntegration", include_prompts: bool = True) -> None:
self.include_prompts = include_prompts
def __init__(
self: "LiteLLMIntegration", include_prompts: "Optional[bool]" = None
) -> None:
if include_prompts is not None:
warnings.warn(
"`LiteLLMIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
"To disable capture of GenAI attributes, pass "
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
"to `sentry_sdk.init`.",
DeprecationWarning,
stacklevel=2,
)

self.include_prompts = True if include_prompts is None else include_prompts

@staticmethod
def setup_once() -> None:
Expand Down
15 changes: 13 additions & 2 deletions sentry_sdk/integrations/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

import inspect
import warnings
from collections.abc import Iterator
from contextlib import contextmanager
from functools import wraps
Expand Down Expand Up @@ -80,15 +81,25 @@ class MCPIntegration(Integration):
identifier = "mcp"
origin = "auto.ai.mcp"

def __init__(self, include_prompts: bool = True) -> None:
def __init__(self, include_prompts: "Optional[bool]" = None) -> None:
"""
Initialize the MCP integration.

Args:
include_prompts: Whether to include prompts (tool results and prompt content)
in span data. Requires send_default_pii=True. Default is True.
"""
self.include_prompts = include_prompts
if include_prompts is not None:
warnings.warn(
"`MCPIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
"To disable capture of GenAI attributes, pass "
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
"to `sentry_sdk.init`.",
DeprecationWarning,
stacklevel=2,
)

self.include_prompts = True if include_prompts is None else include_prompts

@staticmethod
def setup_once() -> None:
Expand Down
15 changes: 13 additions & 2 deletions sentry_sdk/integrations/openai.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import sys
import time
import warnings
from collections.abc import Iterable
from functools import wraps
from typing import TYPE_CHECKING, cast
Expand Down Expand Up @@ -123,10 +124,20 @@ class OpenAIIntegration(Integration):

def __init__(
self: "OpenAIIntegration",
include_prompts: bool = True,
include_prompts: "Optional[bool]" = None,
tiktoken_encoding_name: "Optional[str]" = None,
) -> None:
self.include_prompts = include_prompts
if include_prompts is not None:
warnings.warn(
"`OpenAIIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
"To disable capture of GenAI attributes, pass "
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
"to `sentry_sdk.init`.",
DeprecationWarning,
stacklevel=2,
)

self.include_prompts = True if include_prompts is None else include_prompts

self.tiktoken_encoding = None
if tiktoken_encoding_name is not None:
Expand Down
19 changes: 16 additions & 3 deletions sentry_sdk/integrations/pydantic_ai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import functools
import warnings

from sentry_sdk.integrations import DidNotEnable, Integration
from sentry_sdk.utils import parse_version
Expand All @@ -21,7 +22,7 @@
from .spans.ai_client import ai_client_span, update_ai_client_span

if TYPE_CHECKING:
from typing import Any
from typing import Any, Optional

from pydantic_ai import ModelRequestContext, RunContext
from pydantic_ai.capabilities import Hooks, WrapModelRequestHandler
Expand Down Expand Up @@ -84,7 +85,9 @@ class PydanticAIIntegration(Integration):
origin = f"auto.ai.{identifier}"

def __init__(
self, include_prompts: bool = True, handled_tool_call_exceptions: bool = True
self,
include_prompts: "Optional[bool]" = None,
handled_tool_call_exceptions: bool = True,
) -> None:
"""
Initialize the Pydantic AI integration.
Expand All @@ -95,7 +98,17 @@ def __init__(
handled_tool_exceptions: Capture tool call exceptions that Pydantic AI
internally prevents from bubbling up.
"""
self.include_prompts = include_prompts
if include_prompts is not None:
warnings.warn(
"`PydanticAIIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
"To disable capture of GenAI attributes, pass "
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
"to `sentry_sdk.init`.",
DeprecationWarning,
stacklevel=2,
)

self.include_prompts = True if include_prompts is None else include_prompts
self.handled_tool_call_exceptions = handled_tool_call_exceptions

@staticmethod
Expand Down
Loading