Skip to content

Commit 045fadc

Browse files
committed
ref(data-collection): simplify database collection config to a plain boolean
The `database` option was a nested `DatabaseCollectionUserOptions`/ `DatabaseCollectionBehaviour` TypedDict with a single `query_params` field, adding indirection for no benefit. Collapse it to a plain `bool`, matching `queues`.
1 parent 5cc008c commit 045fadc

3 files changed

Lines changed: 7 additions & 22 deletions

File tree

sentry_sdk/_types.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,6 @@ class GraphQLCollectionBehaviour(TypedDict):
172172
document: bool
173173
variables: bool
174174

175-
class DatabaseCollectionUserOptions(TypedDict, total=False):
176-
query_params: bool
177-
178-
class DatabaseCollectionBehaviour(TypedDict):
179-
query_params: bool
180-
181175
class HttpHeadersCollectionUserOptions(TypedDict, total=False):
182176
request: "KeyValueCollectionBehaviour"
183177

@@ -192,7 +186,7 @@ class DataCollectionUserOptions(TypedDict, total=False):
192186
query_params: "KeyValueCollectionBehaviour"
193187
graphql: "GraphQLCollectionUserOptions"
194188
gen_ai: "GenAICollectionUserOptions"
195-
database: "DatabaseCollectionUserOptions"
189+
database: bool
196190
queues: bool
197191
stack_frame_variables: bool
198192
frame_context_lines: int
@@ -206,7 +200,7 @@ class DataCollection(TypedDict):
206200
query_params: "KeyValueCollectionBehaviour"
207201
graphql: "GraphQLCollectionBehaviour"
208202
gen_ai: "GenAICollectionBehaviour"
209-
database: "DatabaseCollectionBehaviour"
203+
database: bool
210204
queues: bool
211205
stack_frame_variables: bool
212206
frame_context_lines: int

sentry_sdk/data_collection.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from typing import Any, Dict, Literal
3030

3131
from sentry_sdk._types import (
32-
DatabaseCollectionBehaviour,
3332
DataCollection,
3433
GenAICollectionBehaviour,
3534
GraphQLCollectionBehaviour,
@@ -107,7 +106,7 @@ def _map_from_send_default_pii(
107106
"query_params": {"mode": kv_mode, "terms": terms},
108107
"graphql": {"document": send_default_pii, "variables": send_default_pii},
109108
"gen_ai": {"inputs": send_default_pii, "outputs": send_default_pii},
110-
"database": {"query_params": send_default_pii},
109+
"database": send_default_pii,
111110
"queues": send_default_pii,
112111
"stack_frame_variables": include_local_variables,
113112
"frame_context_lines": (
@@ -157,7 +156,7 @@ def _resolve_explicit(
157156
"query_params": _kvcb_from_value(d.get("query_params") or {}),
158157
"graphql": _graphql_from_value(d.get("graphql") or {}),
159158
"gen_ai": _gen_ai_from_value(d.get("gen_ai") or {}),
160-
"database": _database_from_value(d.get("database") or {}),
159+
"database": d.get("database", True),
161160
"queues": d.get("queues", True),
162161
"stack_frame_variables": stack_frame_variables,
163162
"frame_context_lines": frame_context_lines,
@@ -211,12 +210,6 @@ def _graphql_from_value(
211210
}
212211

213212

214-
def _database_from_value(
215-
val: "dict[str, Any]",
216-
) -> "DatabaseCollectionBehaviour":
217-
return {"query_params": val.get("query_params", True)}
218-
219-
220213
def _resolve_data_collection(options: "Dict[str, Any]") -> "DataCollection":
221214
"""
222215
Resolve the effective ``DataCollection`` dict from client ``options``.

tests/test_data_collection.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ def _get(dc, path):
166166
"query_params": None,
167167
"graphql": None,
168168
"gen_ai": None,
169-
"database": None,
170169
}
171170
},
172171
{
@@ -177,7 +176,6 @@ def _get(dc, path):
177176
"graphql.variables": True,
178177
"gen_ai.inputs": True,
179178
"gen_ai.outputs": True,
180-
"database.query_params": True,
181179
},
182180
id="none_values_fall_back_to_spec_defaults",
183181
),
@@ -186,7 +184,7 @@ def _get(dc, path):
186184
{
187185
"graphql.document": True,
188186
"graphql.variables": True,
189-
"database.query_params": True,
187+
"database": True,
190188
},
191189
id="explicit_graphql_database_defaults",
192190
),
@@ -195,7 +193,7 @@ def _get(dc, path):
195193
{
196194
"graphql.document": False,
197195
"graphql.variables": False,
198-
"database.query_params": False,
196+
"database": False,
199197
"queues": False,
200198
},
201199
id="legacy_pii_off_gates_graphql_database_and_queues",
@@ -205,7 +203,7 @@ def _get(dc, path):
205203
{
206204
"graphql.document": True,
207205
"graphql.variables": True,
208-
"database.query_params": True,
206+
"database": True,
209207
"queues": True,
210208
},
211209
id="legacy_pii_on_collects_graphql_database_and_queues",

0 commit comments

Comments
 (0)