@@ -438,129 +438,6 @@ def test_oversized_request_body_not_annotated_data_collection(
438438 assert "http.request.body.data" not in server_span ["attributes" ]
439439
440440
441- @pytest .mark .parametrize (
442- "data_collection, expect_body" ,
443- [
444- pytest .param ({}, True , id = "data_collection_http_bodies_default" ),
445- pytest .param (
446- {"http_bodies" : ["incoming_request" ]},
447- True ,
448- id = "data_collection_http_bodies_incoming_request" ,
449- ),
450- pytest .param (
451- {"http_bodies" : ["outgoing_request" ]},
452- False ,
453- id = "data_collection_http_bodies_outgoing_request_only" ,
454- ),
455- pytest .param (
456- {"http_bodies" : []}, False , id = "data_collection_http_bodies_empty"
457- ),
458- ],
459- )
460- def test_request_body_data_collection_span_streaming (
461- tornado_testcase , sentry_init , capture_items , data_collection , expect_body
462- ):
463- sentry_init (
464- integrations = [TornadoIntegration ()],
465- traces_sample_rate = 1.0 ,
466- trace_lifecycle = "stream" ,
467- _experiments = {"data_collection" : data_collection },
468- )
469-
470- items = capture_items ("span" )
471-
472- client = tornado_testcase (Application ([(r"/hi" , HelloHandler )]))
473- response = client .fetch ("/hi" , method = "POST" , body = b"heyoo" )
474- assert response .code == 200
475-
476- sentry_sdk .flush ()
477-
478- (server_span ,) = [item .payload for item in items ]
479-
480- if expect_body :
481- assert server_span ["attributes" ]["http.request.body.data" ] == "heyoo"
482- else :
483- assert "http.request.body.data" not in server_span ["attributes" ]
484-
485-
486- @pytest .mark .parametrize (
487- "data_collection, expect_body" ,
488- [
489- pytest .param ({}, True , id = "data_collection_http_bodies_default" ),
490- pytest .param (
491- {"http_bodies" : ["incoming_request" ]},
492- True ,
493- id = "data_collection_http_bodies_incoming_request" ,
494- ),
495- pytest .param (
496- {"http_bodies" : ["outgoing_request" ]},
497- False ,
498- id = "data_collection_http_bodies_outgoing_request_only" ,
499- ),
500- pytest .param (
501- {"http_bodies" : []}, False , id = "data_collection_http_bodies_empty"
502- ),
503- ],
504- )
505- def test_request_body_data_collection_event_processor (
506- tornado_testcase , sentry_init , capture_events , data_collection , expect_body
507- ):
508- sentry_init (
509- integrations = [TornadoIntegration ()],
510- trace_lifecycle = "static" ,
511- _experiments = {"data_collection" : data_collection },
512- )
513-
514- events = capture_events ()
515-
516- data = {"hey" : 42 }
517- client = tornado_testcase (Application ([(r"/hi" , CrashingHandler )]))
518- response = client .fetch (
519- "/hi" ,
520- method = "POST" ,
521- body = json .dumps (data ),
522- headers = {"Content-Type" : "application/json" },
523- )
524- assert response .code == 500
525-
526- sentry_sdk .flush ()
527-
528- (event ,) = events
529-
530- if expect_body :
531- assert event ["request" ]["data" ] == data
532- else :
533- assert "data" not in event ["request" ]
534-
535-
536- def test_oversized_request_body_not_annotated_data_collection_span_streaming (
537- tornado_testcase , sentry_init , capture_items
538- ):
539- """
540- The gating happens before the size check, so an oversized body is dropped
541- outright instead of being reported as removed because of the size limit.
542- """
543- sentry_init (
544- integrations = [TornadoIntegration ()],
545- traces_sample_rate = 1.0 ,
546- trace_lifecycle = "stream" ,
547- max_request_body_size = "small" ,
548- _experiments = {"data_collection" : {"http_bodies" : []}},
549- )
550-
551- items = capture_items ("span" )
552-
553- client = tornado_testcase (Application ([(r"/hi" , HelloHandler )]))
554- response = client .fetch ("/hi" , method = "POST" , body = b"a" * 2000 )
555- assert response .code == 200
556-
557- sentry_sdk .flush ()
558-
559- (server_span ,) = [item .payload for item in items ]
560-
561- assert "http.request.body.data" not in server_span ["attributes" ]
562-
563-
564441@pytest .mark .parametrize ("send_pii" , [True , False ])
565442@pytest .mark .parametrize (
566443 "handler,code" ,
0 commit comments