diff --git a/sentry_sdk/integrations/anthropic.py b/sentry_sdk/integrations/anthropic.py index 23bdbbb06e..2a34f74e3f 100644 --- a/sentry_sdk/integrations/anthropic.py +++ b/sentry_sdk/integrations/anthropic.py @@ -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 @@ -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: diff --git a/sentry_sdk/integrations/cohere.py b/sentry_sdk/integrations/cohere.py index 9cac912a2b..012b7bae8d 100644 --- a/sentry_sdk/integrations/cohere.py +++ b/sentry_sdk/integrations/cohere.py @@ -1,4 +1,5 @@ import sys +import warnings from functools import wraps from typing import TYPE_CHECKING @@ -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 @@ -78,8 +79,20 @@ class CohereIntegration(Integration): 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: + 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 @staticmethod def setup_once() -> None: diff --git a/sentry_sdk/integrations/google_genai/__init__.py b/sentry_sdk/integrations/google_genai/__init__.py index 8e3871595d..ae22917d6d 100644 --- a/sentry_sdk/integrations/google_genai/__init__.py +++ b/sentry_sdk/integrations/google_genai/__init__.py @@ -1,3 +1,4 @@ +import warnings from functools import wraps from typing import ( Any, @@ -5,6 +6,7 @@ Callable, Iterator, List, + Optional, ) import sentry_sdk @@ -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: diff --git a/sentry_sdk/integrations/huggingface_hub.py b/sentry_sdk/integrations/huggingface_hub.py index 5980c298c0..20eb4f4224 100644 --- a/sentry_sdk/integrations/huggingface_hub.py +++ b/sentry_sdk/integrations/huggingface_hub.py @@ -1,5 +1,6 @@ import inspect import sys +import warnings from functools import wraps from typing import TYPE_CHECKING, cast @@ -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, @@ -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: diff --git a/sentry_sdk/integrations/langchain.py b/sentry_sdk/integrations/langchain.py index 78242ba92c..7bb2374d33 100644 --- a/sentry_sdk/integrations/langchain.py +++ b/sentry_sdk/integrations/langchain.py @@ -234,10 +234,20 @@ class LangchainIntegration(Integration): 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 self.max_spans = max_spans if max_spans is not None: diff --git a/sentry_sdk/integrations/langgraph.py b/sentry_sdk/integrations/langgraph.py index af287b0fd4..4e5492f1c6 100644 --- a/sentry_sdk/integrations/langgraph.py +++ b/sentry_sdk/integrations/langgraph.py @@ -1,3 +1,4 @@ +import warnings from functools import wraps from typing import Any, Callable, List, Optional @@ -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: diff --git a/sentry_sdk/integrations/litellm.py b/sentry_sdk/integrations/litellm.py index 74adddb7ec..729ec39654 100644 --- a/sentry_sdk/integrations/litellm.py +++ b/sentry_sdk/integrations/litellm.py @@ -1,4 +1,5 @@ import copy +import warnings from typing import TYPE_CHECKING import sentry_sdk @@ -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] @@ -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: diff --git a/sentry_sdk/integrations/mcp.py b/sentry_sdk/integrations/mcp.py index 5fc186f505..5bf5546d18 100644 --- a/sentry_sdk/integrations/mcp.py +++ b/sentry_sdk/integrations/mcp.py @@ -8,6 +8,7 @@ """ import inspect +import warnings from collections.abc import Iterator from contextlib import contextmanager from functools import wraps @@ -80,7 +81,7 @@ 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. @@ -88,7 +89,17 @@ def __init__(self, include_prompts: bool = True) -> None: 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: diff --git a/sentry_sdk/integrations/openai.py b/sentry_sdk/integrations/openai.py index 742b693245..d46eb854dc 100644 --- a/sentry_sdk/integrations/openai.py +++ b/sentry_sdk/integrations/openai.py @@ -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 @@ -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: diff --git a/sentry_sdk/integrations/pydantic_ai/__init__.py b/sentry_sdk/integrations/pydantic_ai/__init__.py index a3215aa284..b8391ff55b 100644 --- a/sentry_sdk/integrations/pydantic_ai/__init__.py +++ b/sentry_sdk/integrations/pydantic_ai/__init__.py @@ -1,4 +1,5 @@ import functools +import warnings from sentry_sdk.integrations import DidNotEnable, Integration from sentry_sdk.utils import parse_version @@ -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 @@ -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. @@ -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