|
9 | 9 | from sqlalchemy.orm import relationship, sessionmaker |
10 | 10 |
|
11 | 11 | import sentry_sdk |
12 | | -from sentry_sdk import capture_message, start_transaction |
| 12 | +from sentry_sdk import capture_message |
13 | 13 | from sentry_sdk.consts import SPANDATA |
14 | 14 | from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration |
15 | | -from sentry_sdk.serializer import MAX_EVENT_BYTES |
16 | 15 | from sentry_sdk.tracing_utils import record_sql_queries |
17 | | -from sentry_sdk.utils import json_dumps |
18 | 16 |
|
19 | 17 |
|
20 | 18 | def test_orm_queries( |
@@ -259,68 +257,6 @@ def test_long_sql_query_preserved( |
259 | 257 | assert name.endswith("SELECT 98 UNION SELECT 99") |
260 | 258 |
|
261 | 259 |
|
262 | | -@pytest.mark.parametrize("max_value_length", [1024, None]) |
263 | | -def test_large_event_not_truncated(sentry_init, capture_events, max_value_length): |
264 | | - sentry_init( |
265 | | - traces_sample_rate=1, |
266 | | - integrations=[SqlalchemyIntegration()], |
267 | | - max_value_length=max_value_length, |
268 | | - trace_lifecycle="stream", |
269 | | - ) |
270 | | - events = capture_events() |
271 | | - |
272 | | - long_str = "x" * (1034) |
273 | | - |
274 | | - scope = sentry_sdk.get_isolation_scope() |
275 | | - |
276 | | - @scope.add_event_processor |
277 | | - def processor(event, hint): |
278 | | - event["message"] = long_str |
279 | | - return event |
280 | | - |
281 | | - engine = create_engine( |
282 | | - "sqlite:///:memory:", connect_args={"check_same_thread": False} |
283 | | - ) |
284 | | - with start_transaction(name="test"): |
285 | | - with engine.connect() as con: |
286 | | - for _ in range(1500): |
287 | | - con.execute( |
288 | | - text(" UNION ".join("SELECT {}".format(i) for i in range(100))) |
289 | | - ) |
290 | | - |
291 | | - (event,) = events |
292 | | - |
293 | | - assert len(json_dumps(event)) > MAX_EVENT_BYTES |
294 | | - |
295 | | - # Some spans are discarded. |
296 | | - assert len(event["spans"]) == 1000 |
297 | | - |
298 | | - # Span descriptions are not truncated. |
299 | | - description = event["spans"][0]["description"] |
300 | | - assert len(description) == 1583 |
301 | | - assert description.startswith("SELECT 0") |
302 | | - assert description.endswith("SELECT 98 UNION SELECT 99") |
303 | | - |
304 | | - description = event["spans"][999]["description"] |
305 | | - assert len(description) == 1583 |
306 | | - assert description.startswith("SELECT 0") |
307 | | - assert description.endswith("SELECT 98 UNION SELECT 99") |
308 | | - |
309 | | - if max_value_length: |
310 | | - # Smoke check that truncation of other fields has not changed. |
311 | | - assert len(event["message"]) == 1024 |
312 | | - |
313 | | - # The _meta for other truncated fields should be there as well. |
314 | | - assert event["_meta"]["message"] == { |
315 | | - "": { |
316 | | - "len": 1034, |
317 | | - "rem": [["!limit", "x", 1021, 1024]], |
318 | | - } |
319 | | - } |
320 | | - else: |
321 | | - assert len(event["message"]) == 1034 |
322 | | - |
323 | | - |
324 | 260 | def test_engine_name_not_string( |
325 | 261 | sentry_init, |
326 | 262 | ): |
|
0 commit comments