Skip to content

Commit 8d3e5ab

Browse files
chore: Deprecate include_prompts parameters
1 parent 85e7ce6 commit 8d3e5ab

10 files changed

Lines changed: 141 additions & 21 deletions

File tree

‎sentry_sdk/integrations/anthropic.py‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import sys
3+
import warnings
34
from collections.abc import Iterable
45
from functools import wraps
56
from typing import TYPE_CHECKING, cast
@@ -222,8 +223,20 @@ class AnthropicIntegration(Integration):
222223
identifier = "anthropic"
223224
origin = f"auto.ai.{identifier}"
224225

225-
def __init__(self: "AnthropicIntegration", include_prompts: bool = True) -> None:
226-
self.include_prompts = include_prompts
226+
def __init__(
227+
self: "AnthropicIntegration", include_prompts: "Optional[bool]" = None
228+
) -> None:
229+
if include_prompts is not None:
230+
warnings.warn(
231+
"`AnthropicIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
232+
"To disable capture of GenAI attributes, pass "
233+
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
234+
"to `sentry_sdk.init`.",
235+
DeprecationWarning,
236+
stacklevel=2,
237+
)
238+
239+
self.include_prompts = True if include_prompts is None else include_prompts
227240

228241
@staticmethod
229242
def setup_once() -> None:

‎sentry_sdk/integrations/cohere.py‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import warnings
23
from functools import wraps
34
from typing import TYPE_CHECKING
45

@@ -10,7 +11,7 @@
1011
from sentry_sdk.tracing_utils import has_span_streaming_enabled
1112

1213
if TYPE_CHECKING:
13-
from typing import Any, Callable, Iterator, Union
14+
from typing import Any, Callable, Iterator, Optional, Union
1415

1516
from sentry_sdk.tracing import Span
1617

@@ -78,8 +79,20 @@ class CohereIntegration(Integration):
7879
identifier = "cohere"
7980
origin = f"auto.ai.{identifier}"
8081

81-
def __init__(self: "CohereIntegration", include_prompts: bool = True) -> None:
82-
self.include_prompts = include_prompts
82+
def __init__(
83+
self: "CohereIntegration", include_prompts: "Optional[bool]" = True
84+
) -> None:
85+
if include_prompts is not None:
86+
warnings.warn(
87+
"`CohereIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
88+
"To disable capture of GenAI attributes, pass "
89+
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
90+
"to `sentry_sdk.init`.",
91+
DeprecationWarning,
92+
stacklevel=2,
93+
)
94+
95+
self.include_prompts = True if include_prompts is None else include_prompts
8396

8497
@staticmethod
8598
def setup_once() -> None:

‎sentry_sdk/integrations/google_genai/__init__.py‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import warnings
12
from functools import wraps
23
from typing import (
34
Any,
45
AsyncIterator,
56
Callable,
67
Iterator,
78
List,
9+
Optional,
810
)
911

1012
import sentry_sdk
@@ -41,8 +43,20 @@ class GoogleGenAIIntegration(Integration):
4143
identifier = IDENTIFIER
4244
origin = ORIGIN
4345

44-
def __init__(self: "GoogleGenAIIntegration", include_prompts: bool = True) -> None:
45-
self.include_prompts = include_prompts
46+
def __init__(
47+
self: "GoogleGenAIIntegration", include_prompts: "Optional[bool]" = None
48+
) -> None:
49+
if include_prompts is not None:
50+
warnings.warn(
51+
"`GoogleGenAIIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
52+
"To disable capture of GenAI attributes, pass "
53+
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
54+
"to `sentry_sdk.init`.",
55+
DeprecationWarning,
56+
stacklevel=2,
57+
)
58+
59+
self.include_prompts = True if include_prompts is None else include_prompts
4660

4761
@staticmethod
4862
def setup_once() -> None:

‎sentry_sdk/integrations/huggingface_hub.py‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import inspect
22
import sys
3+
import warnings
34
from functools import wraps
45
from typing import TYPE_CHECKING, cast
56

@@ -23,7 +24,7 @@
2324
)
2425

2526
if TYPE_CHECKING:
26-
from typing import Any, Callable, Iterable, Union
27+
from typing import Any, Callable, Iterable, Optional, Union
2728

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

4445
def __init__(
45-
self: "HuggingfaceHubIntegration", include_prompts: bool = True
46+
self: "HuggingfaceHubIntegration", include_prompts: "Optional[bool]" = None
4647
) -> None:
47-
self.include_prompts = include_prompts
48+
if include_prompts is not None:
49+
warnings.warn(
50+
"`HuggingfaceHubIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
51+
"To disable capture of GenAI attributes, pass "
52+
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
53+
"to `sentry_sdk.init`.",
54+
DeprecationWarning,
55+
stacklevel=2,
56+
)
57+
58+
self.include_prompts = True if include_prompts is None else include_prompts
4859

4960
@staticmethod
5061
def setup_once() -> None:

‎sentry_sdk/integrations/langchain.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,17 @@ def __init__(
237237
include_prompts: bool = True,
238238
max_spans: "Optional[int]" = None,
239239
) -> None:
240-
self.include_prompts = include_prompts
240+
if include_prompts is not None:
241+
warnings.warn(
242+
"`LangchainIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
243+
"To disable capture of GenAI attributes, pass "
244+
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
245+
"to `sentry_sdk.init`.",
246+
DeprecationWarning,
247+
stacklevel=2,
248+
)
249+
250+
self.include_prompts = True if include_prompts is None else include_prompts
241251
self.max_spans = max_spans
242252

243253
if max_spans is not None:

‎sentry_sdk/integrations/langgraph.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from functools import wraps
23
from typing import Any, Callable, List, Optional
34

@@ -34,7 +35,17 @@ class LanggraphIntegration(Integration):
3435
origin = f"auto.ai.{identifier}"
3536

3637
def __init__(self: "LanggraphIntegration", include_prompts: bool = True) -> None:
37-
self.include_prompts = include_prompts
38+
if include_prompts is not None:
39+
warnings.warn(
40+
"`LanggraphIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
41+
"To disable capture of GenAI attributes, pass "
42+
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
43+
"to `sentry_sdk.init`.",
44+
DeprecationWarning,
45+
stacklevel=2,
46+
)
47+
48+
self.include_prompts = True if include_prompts is None else include_prompts
3849

3950
@staticmethod
4051
def setup_once() -> None:

‎sentry_sdk/integrations/litellm.py‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import copy
2+
import warnings
23
from typing import TYPE_CHECKING
34

45
import sentry_sdk
@@ -22,7 +23,7 @@
2223

2324
if TYPE_CHECKING:
2425
from datetime import datetime
25-
from typing import Any, Dict, List
26+
from typing import Any, Dict, List, Optional
2627

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

367-
def __init__(self: "LiteLLMIntegration", include_prompts: bool = True) -> None:
368-
self.include_prompts = include_prompts
368+
def __init__(
369+
self: "LiteLLMIntegration", include_prompts: "Optional[bool]" = None
370+
) -> None:
371+
if include_prompts is not None:
372+
warnings.warn(
373+
"`LiteLLMIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
374+
"To disable capture of GenAI attributes, pass "
375+
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
376+
"to `sentry_sdk.init`.",
377+
DeprecationWarning,
378+
stacklevel=2,
379+
)
380+
381+
self.include_prompts = True if include_prompts is None else include_prompts
369382

370383
@staticmethod
371384
def setup_once() -> None:

‎sentry_sdk/integrations/mcp.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
import inspect
11+
import warnings
1112
from collections.abc import Iterator
1213
from contextlib import contextmanager
1314
from functools import wraps
@@ -88,7 +89,17 @@ def __init__(self, include_prompts: bool = True) -> None:
8889
include_prompts: Whether to include prompts (tool results and prompt content)
8990
in span data. Requires send_default_pii=True. Default is True.
9091
"""
91-
self.include_prompts = include_prompts
92+
if include_prompts is not None:
93+
warnings.warn(
94+
"`MCPIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
95+
"To disable capture of GenAI attributes, pass "
96+
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
97+
"to `sentry_sdk.init`.",
98+
DeprecationWarning,
99+
stacklevel=2,
100+
)
101+
102+
self.include_prompts = True if include_prompts is None else include_prompts
92103

93104
@staticmethod
94105
def setup_once() -> None:

‎sentry_sdk/integrations/openai.py‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import sys
33
import time
4+
import warnings
45
from collections.abc import Iterable
56
from functools import wraps
67
from typing import TYPE_CHECKING, cast
@@ -123,10 +124,20 @@ class OpenAIIntegration(Integration):
123124

124125
def __init__(
125126
self: "OpenAIIntegration",
126-
include_prompts: bool = True,
127+
include_prompts: Optional[bool] = None,
127128
tiktoken_encoding_name: "Optional[str]" = None,
128129
) -> None:
129-
self.include_prompts = include_prompts
130+
if include_prompts is not None:
131+
warnings.warn(
132+
"`OpenAIIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
133+
"To disable capture of GenAI attributes, pass "
134+
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
135+
"to `sentry_sdk.init`.",
136+
DeprecationWarning,
137+
stacklevel=2,
138+
)
139+
140+
self.include_prompts = True if include_prompts is None else include_prompts
130141

131142
self.tiktoken_encoding = None
132143
if tiktoken_encoding_name is not None:

‎sentry_sdk/integrations/pydantic_ai/__init__.py‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import functools
2+
import warnings
23

34
from sentry_sdk.integrations import DidNotEnable, Integration
45
from sentry_sdk.utils import parse_version
@@ -21,7 +22,7 @@
2122
from .spans.ai_client import ai_client_span, update_ai_client_span
2223

2324
if TYPE_CHECKING:
24-
from typing import Any
25+
from typing import Any, Optional
2526

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

8687
def __init__(
87-
self, include_prompts: bool = True, handled_tool_call_exceptions: bool = True
88+
self,
89+
include_prompts: Optional[bool] = None,
90+
handled_tool_call_exceptions: bool = True,
8891
) -> None:
8992
"""
9093
Initialize the Pydantic AI integration.
@@ -95,7 +98,17 @@ def __init__(
9598
handled_tool_exceptions: Capture tool call exceptions that Pydantic AI
9699
internally prevents from bubbling up.
97100
"""
98-
self.include_prompts = include_prompts
101+
if include_prompts is not None:
102+
warnings.warn(
103+
"`PydanticAIIntegration.include_prompts` is deprecated and will be removed in version 3.0. "
104+
"To disable capture of GenAI attributes, pass "
105+
"`data_collection={'gen_ai': {'inputs': False, 'outputs': False}}` "
106+
"to `sentry_sdk.init`.",
107+
DeprecationWarning,
108+
stacklevel=2,
109+
)
110+
111+
self.include_prompts = True if include_prompts is None else include_prompts
99112
self.handled_tool_call_exceptions = handled_tool_call_exceptions
100113

101114
@staticmethod

0 commit comments

Comments
 (0)