Commit 6eacecc
fix(starlette): Set request body data on segment under streaming
Under span streaming with middleware_spans=True, sentry_sdk.get_current_span() returns the innermost middleware span rather than the segment, so http.request.body.data was being attached to a middleware child span. Route the attribute through current_span._segment so it always lands on the segment, mirroring the _update_active_thread pattern in _sentry_sync_func.
Also deduplicate the sentry_sdk.get_client() call in _sentry_async_func, and parametrize the three body-data streaming tests over middleware_spans=[False, True].
Refs PY-2362
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 50352ea commit 6eacecc
2 files changed
Lines changed: 14 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | | - | |
473 | | - | |
474 | | - | |
| 472 | + | |
| 473 | + | |
475 | 474 | | |
476 | 475 | | |
477 | 476 | | |
| |||
511 | 510 | | |
512 | 511 | | |
513 | 512 | | |
514 | | - | |
515 | 513 | | |
516 | 514 | | |
517 | 515 | | |
| |||
523 | 521 | | |
524 | 522 | | |
525 | 523 | | |
526 | | - | |
| 524 | + | |
527 | 525 | | |
528 | 526 | | |
529 | 527 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1066 | 1066 | | |
1067 | 1067 | | |
1068 | 1068 | | |
1069 | | - | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
1070 | 1073 | | |
1071 | 1074 | | |
1072 | | - | |
| 1075 | + | |
1073 | 1076 | | |
1074 | 1077 | | |
1075 | 1078 | | |
| |||
1107 | 1110 | | |
1108 | 1111 | | |
1109 | 1112 | | |
| 1113 | + | |
1110 | 1114 | | |
1111 | | - | |
| 1115 | + | |
1112 | 1116 | | |
1113 | 1117 | | |
1114 | 1118 | | |
1115 | | - | |
| 1119 | + | |
1116 | 1120 | | |
1117 | 1121 | | |
1118 | 1122 | | |
| |||
1140 | 1144 | | |
1141 | 1145 | | |
1142 | 1146 | | |
| 1147 | + | |
1143 | 1148 | | |
1144 | | - | |
| 1149 | + | |
1145 | 1150 | | |
1146 | 1151 | | |
1147 | 1152 | | |
1148 | 1153 | | |
1149 | 1154 | | |
1150 | | - | |
| 1155 | + | |
1151 | 1156 | | |
1152 | 1157 | | |
1153 | 1158 | | |
| |||
0 commit comments