Commit e882029
authored
feat(fastapi): Support span streaming in active thread tracking (#6118)
Support span-first functionality in the FastAPI integration's active
thread tracking, while continuing to support the legacy
transaction-based path.
When the span streaming experiment (`trace_lifecycle: "stream"`) is
enabled, `current_scope.transaction` is `None` and the scope instead
holds a `StreamedSpan`. The existing profiler hook in
`patch_get_request_handler` only called
`current_scope.transaction.update_active_thread()`, so under streaming
the profiler's `thread.id` was never attached to the segment. This PR
detects the `StreamedSpan` case and calls `_update_active_thread()` on
its segment; the legacy transaction path is preserved unchanged.
Tests are parametrized across streaming and static modes where relevant,
and a dedicated test asserts that the active thread id ends up on the
segment's attributes when streaming is enabled.
Refs PY-2322
Fixes #60201 parent 21f78df commit e882029
2 files changed
Lines changed: 69 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
84 | 92 | | |
85 | 93 | | |
86 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
223 | 249 | | |
224 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
225 | 253 | | |
| 254 | + | |
226 | 255 | | |
227 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
228 | 260 | | |
229 | 261 | | |
230 | 262 | | |
| |||
344 | 376 | | |
345 | 377 | | |
346 | 378 | | |
| 379 | + | |
347 | 380 | | |
348 | 381 | | |
349 | 382 | | |
| |||
368 | 401 | | |
369 | 402 | | |
370 | 403 | | |
| 404 | + | |
| 405 | + | |
371 | 406 | | |
372 | 407 | | |
373 | 408 | | |
| |||
379 | 414 | | |
380 | 415 | | |
381 | 416 | | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
382 | 420 | | |
383 | 421 | | |
384 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
385 | 426 | | |
386 | 427 | | |
387 | 428 | | |
388 | 429 | | |
389 | 430 | | |
390 | 431 | | |
391 | | - | |
392 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
393 | 444 | | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
398 | 450 | | |
399 | 451 | | |
400 | 452 | | |
| |||
0 commit comments