Skip to content

Commit 5ff35c7

Browse files
authored
Merge branch 'master' into fix/serializer-large-mapping-copy
2 parents 3f0f2a8 + fbc85c1 commit 5ff35c7

40 files changed

Lines changed: 1746 additions & 295 deletions

.claude/settings.json

Lines changed: 0 additions & 48 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
11
# Changelog
22

3+
## 2.65.0
4+
5+
### New Features ✨
6+
7+
#### Huey
8+
9+
- Set `messaging.destination.name` on consumer spans by @alexander-alderman-webb in [#6779](https://github.com/getsentry/sentry-python/pull/6779)
10+
- Set `messaging.destination.name` on producer spans by @alexander-alderman-webb in [#6778](https://github.com/getsentry/sentry-python/pull/6778)
11+
12+
#### Other
13+
14+
- (arq) Set `messaging.destination.name` on consumer spans by @alexander-alderman-webb in [#6767](https://github.com/getsentry/sentry-python/pull/6767)
15+
- (dramatiq) Set `messaging.destination.name` on consumer spans by @alexander-alderman-webb in [#6776](https://github.com/getsentry/sentry-python/pull/6776)
16+
- (rq) Set `messaging.destination.name` on consumer spans by @alexander-alderman-webb in [#6774](https://github.com/getsentry/sentry-python/pull/6774)
17+
18+
### Bug Fixes 🐛
19+
20+
#### Tracing
21+
22+
- Take first sentry-trace header in case multiple are supplied by @sl0thentr0py in [#6722](https://github.com/getsentry/sentry-python/pull/6722)
23+
24+
#### Other
25+
26+
- (django) Avoid `ValueError` in async middleware `process_*` hooks by @r0ro in [#6698](https://github.com/getsentry/sentry-python/pull/6698)
27+
- (scope) Drop None user attribute values in set_user by @ericapisani in [#6692](https://github.com/getsentry/sentry-python/pull/6692)
28+
- (starlette) Don't overwrite user set during request in AuthenticationMiddleware by @ericapisani in [#6760](https://github.com/getsentry/sentry-python/pull/6760)
29+
30+
### Internal Changes 🔧
31+
32+
- (mcp) Add package to the typing group by @alexander-alderman-webb in [#6727](https://github.com/getsentry/sentry-python/pull/6727)
33+
- (starlette) Add package to typing group by @alexander-alderman-webb in [#6728](https://github.com/getsentry/sentry-python/pull/6728)
34+
- Add required `cache_write_tokens` field by @alexander-alderman-webb in [#6804](https://github.com/getsentry/sentry-python/pull/6804)
35+
- Pin extra test dependencies for generated test suites by @alexander-alderman-webb in [#6696](https://github.com/getsentry/sentry-python/pull/6696)
36+
- Add `pydantic` to the typing group by @alexander-alderman-webb in [#6730](https://github.com/getsentry/sentry-python/pull/6730)
37+
- Add `python_multipart` to the typing group by @alexander-alderman-webb in [#6729](https://github.com/getsentry/sentry-python/pull/6729)
38+
- 🤖 Update test matrix with new releases (07/06) by @github-actions in [#6753](https://github.com/getsentry/sentry-python/pull/6753)
39+
- Remove dependabot by @alexander-alderman-webb in [#6720](https://github.com/getsentry/sentry-python/pull/6720)
40+
- Update Renovate config by @alexander-alderman-webb in [#6716](https://github.com/getsentry/sentry-python/pull/6716)
41+
- Stop inheriting secrets for `changelog-preview` by @alexander-alderman-webb in [#6723](https://github.com/getsentry/sentry-python/pull/6723)
42+
- Stop inheriting secrets in tests by @alexander-alderman-webb in [#6721](https://github.com/getsentry/sentry-python/pull/6721)
43+
- Configure Renovate by @renovate in [#6701](https://github.com/getsentry/sentry-python/pull/6701)
44+
- Move conversation ID tests to their own file by @sentrivana in [#6699](https://github.com/getsentry/sentry-python/pull/6699)
45+
- Replace `requirements-testing.txt` with a `uv` dependency group by @alexander-alderman-webb in [#6693](https://github.com/getsentry/sentry-python/pull/6693)
46+
347
## 2.64.0
448

549
The SDK now extracts all `gen_ai` spans out of a transaction and sends them as v2 envelope items by default. This prevents `gen_ai` spans from being dropped when the transaction payload exceeds size limits. Because they are no longer constrained by transaction size limits, AI message data is also no longer truncated. To keep the previous behavior, set `stream_gen_ai_spans=False`.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ sentry_sdk.init(
4949
# Set traces_sample_rate to 1.0 to capture 100%
5050
# of traces for performance monitoring.
5151
traces_sample_rate=1.0,
52+
53+
# To disable sending user data and HTTP request/response bodies, uncomment
54+
# the line below. For more info visit:
55+
# https://docs.sentry.io/platforms/python/configuration/options/#data_collection
56+
# data_collection={"user_info": False, "http_bodies": []},
5257
)
5358
```
5459

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
copyright = "2019-{}, Sentry Team and Contributors".format(datetime.now().year)
3232
author = "Sentry Team and Contributors"
3333

34-
release = "2.64.0"
34+
release = "2.65.0"
3535
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3636

3737

sentry_sdk/_types.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def substituted_because_contains_sensitive_data(cls) -> "AnnotatedValue":
141141
from collections.abc import Container, MutableMapping, Sequence
142142
from datetime import datetime
143143
from types import TracebackType
144-
from typing import Any, Callable, Dict, Mapping, NotRequired, Optional, Type
144+
from typing import Any, Callable, Dict, List, Mapping, NotRequired, Optional, Type
145145

146146
from typing_extensions import Literal, TypedDict
147147

@@ -152,6 +152,59 @@ class SDKInfo(TypedDict):
152152
version: str
153153
packages: "Sequence[Mapping[str, str]]"
154154

155+
class KeyValueCollectionBehaviour(TypedDict):
156+
mode: 'Literal["off", "denylist", "allowlist"]'
157+
terms: "NotRequired[List[str]]"
158+
159+
class GenAICollectionUserOptions(TypedDict, total=False):
160+
inputs: bool
161+
outputs: bool
162+
163+
class GenAICollectionBehaviour(TypedDict):
164+
inputs: bool
165+
outputs: bool
166+
167+
class GraphQLCollectionUserOptions(TypedDict, total=False):
168+
document: bool
169+
variables: bool
170+
171+
class GraphQLCollectionBehaviour(TypedDict):
172+
document: bool
173+
variables: bool
174+
175+
class HttpHeadersCollectionUserOptions(TypedDict, total=False):
176+
request: "KeyValueCollectionBehaviour"
177+
178+
class HttpHeadersCollectionBehaviour(TypedDict):
179+
request: "KeyValueCollectionBehaviour"
180+
181+
class DataCollectionUserOptions(TypedDict, total=False):
182+
user_info: bool
183+
cookies: "KeyValueCollectionBehaviour"
184+
http_headers: "HttpHeadersCollectionUserOptions"
185+
http_bodies: "List[str]"
186+
query_params: "KeyValueCollectionBehaviour"
187+
graphql: "GraphQLCollectionUserOptions"
188+
gen_ai: "GenAICollectionUserOptions"
189+
database_query_data: bool
190+
queues: bool
191+
stack_frame_variables: bool
192+
frame_context_lines: int
193+
194+
class DataCollection(TypedDict):
195+
provided_by_user: bool
196+
user_info: bool
197+
cookies: "KeyValueCollectionBehaviour"
198+
http_headers: "HttpHeadersCollectionBehaviour"
199+
http_bodies: "List[str]"
200+
query_params: "KeyValueCollectionBehaviour"
201+
graphql: "GraphQLCollectionBehaviour"
202+
gen_ai: "GenAICollectionBehaviour"
203+
database_query_data: bool
204+
queues: bool
205+
stack_frame_variables: bool
206+
frame_context_lines: int
207+
155208
# "critical" is an alias of "fatal" recognized by Relay
156209
LogLevelStr = Literal["fatal", "critical", "error", "warning", "info", "debug"]
157210

sentry_sdk/client.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
VERSION,
2424
ClientConstructor,
2525
)
26+
from sentry_sdk.data_collection import (
27+
_map_from_send_default_pii,
28+
_resolve_data_collection,
29+
)
2630
from sentry_sdk.envelope import Envelope, Item, PayloadRef
2731
from sentry_sdk.integrations import _DEFAULT_INTEGRATIONS, setup_integrations
2832
from sentry_sdk.integrations.dedupe import DedupeIntegration
@@ -345,11 +349,13 @@ def _get_options(*args: "Optional[str]", **kwargs: "Any") -> "Dict[str, Any]":
345349
if rv["enable_tracing"] is True and rv["traces_sample_rate"] is None:
346350
rv["traces_sample_rate"] = 1.0
347351

352+
rv["data_collection"] = _resolve_data_collection(rv)
353+
348354
if rv["event_scrubber"] is None:
349355
rv["event_scrubber"] = EventScrubber(
350-
send_default_pii=(
351-
False if rv["send_default_pii"] is None else rv["send_default_pii"]
352-
)
356+
send_default_pii=False
357+
if rv["send_default_pii"] is None
358+
else rv["send_default_pii"]
353359
)
354360

355361
if rv["socket_options"] and not isinstance(rv["socket_options"], list):
@@ -614,6 +620,19 @@ def _record_lost_event(
614620
self.options["error_sampler"] = sample_all
615621
self.options["traces_sampler"] = sample_all
616622
self.options["profiles_sampler"] = sample_all
623+
# data_collection was resolved in _get_options() before this
624+
# spotlight override flipped send_default_pii on. Re-derive it so
625+
# data_collection agrees with should_send_default_pii() in
626+
# DSN-less spotlight mode (only when the user did not set
627+
# data_collection explicitly).
628+
if not self.options["data_collection"]["provided_by_user"]:
629+
self.options["data_collection"] = _map_from_send_default_pii(
630+
send_default_pii=True,
631+
include_local_variables=self.options["include_local_variables"]
632+
is not False,
633+
include_source_context=self.options["include_source_context"]
634+
is not False,
635+
)
617636

618637
self.session_flusher = SessionFlusher(capture_func=_capture_envelope)
619638

sentry_sdk/consts.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class CompressionAlgo(Enum):
4545
from sentry_sdk._types import (
4646
BreadcrumbProcessor,
4747
ContinuousProfilerMode,
48+
DataCollectionUserOptions,
4849
Event,
4950
EventProcessor,
5051
Hint,
@@ -86,6 +87,7 @@ class CompressionAlgo(Enum):
8687
Callable[[SpanJSON, Hint], Optional[SpanJSON]]
8788
],
8889
"suppress_asgi_chained_exceptions": Optional[bool],
90+
"data_collection": Optional[DataCollectionUserOptions],
8991
},
9092
total=False,
9193
)
@@ -1755,7 +1757,25 @@ def __init__(
17551757
:param stream_gen_ai_spans: When set, generative AI spans are sent in a new transport format to
17561758
reduce downstream data loss.
17571759
1758-
:param _experiments:
1760+
:param _experiments: Dictionary of experimental, opt-in features that are not yet stable.
1761+
1762+
``data_collection`` (EXPERIMENTAL): structured configuration controlling what data integrations
1763+
collect automatically, superseding `send_default_pii`. Passing a dict under
1764+
`_experiments={"data_collection": {...}}` opts into the feature; omitted fields use their
1765+
defaults (most categories are collected, with the sensitive denylist scrubbing values).
1766+
When it is not set, the SDK derives behaviour from `send_default_pii` so that upgrading
1767+
changes nothing. Restrict collection per category (user identity, cookies, HTTP
1768+
headers/bodies, query params, generative AI inputs/outputs, stack frame variables, source
1769+
context). If `send_default_pii` is also set, `data_collection` takes precedence.
1770+
1771+
Example::
1772+
1773+
sentry_sdk.init(
1774+
dsn="...",
1775+
_experiments={"data_collection": {"user_info": False, "http_bodies": []}},
1776+
)
1777+
1778+
See https://docs.sentry.io/platforms/python/configuration/options/#data_collection for more details.
17591779
"""
17601780
pass
17611781

@@ -1779,4 +1799,4 @@ def _get_default_options() -> "dict[str, Any]":
17791799
del _get_default_options
17801800

17811801

1782-
VERSION = "2.64.0"
1802+
VERSION = "2.65.0"

0 commit comments

Comments
 (0)