Commit 80cd1f1
authored
Fix transaction name in Starlette and FastAPI (getsentry#2341)
Set the url as a transaction name instead of 'generic ASGI request' in the beginning, so traces_sampler has something to work with that is more meaningful than 'generic ASGI request'.
Closes getsentry#2262
Closes getsentry#2263
New Behaviour:
Note: transaction names can be two styles, "url" or "endpoint". (set by the transaction_style parameter of the Integrations)
Note 2: See also @pytest.mark.parametrize decorator in the new tests as reference.
vanilla ASGI: set URL instead of always "generic ASGI request"
Starlette:
normal request: transaction name is function name or route (depending on transaction_style setting)
traces_sampler: always receives the raw URL as the transaction name (no matter the transaction_style setting. because we do not know more at the time the traces_sampler is called.)
requests that end in a middleware (like 404, CORS): the functions name or the raw URL (depending on transaction_style setting)
FastAPI
normal request: transaction name is function name or route (depending on transaction_style setting)
traces_sampler: always receives the raw URL as the transaction name (no matter the transaction_style setting. because we do not know more at the time the traces_sampler is called.)
requests that end in a middleware (like 404, CORS): the functions name or the raw URL (depending on transaction_style setting)
There used to be "generic ASGI request" transactions being created at the server startup (when a "lifespan" ASGI message was received.) Those transactions are not created anymore. (we can think of creating propper "Server was started/stopped" transactions in the future)1 parent ba6de38 commit 80cd1f1
5 files changed
Lines changed: 564 additions & 67 deletions
File tree
- sentry_sdk/integrations
- tests/integrations
- asgi
- fastapi
- starlette
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
38 | | - | |
39 | 41 | | |
40 | | - | |
41 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| |||
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
147 | | - | |
| 151 | + | |
| 152 | + | |
148 | 153 | | |
149 | 154 | | |
150 | 155 | | |
| |||
167 | 172 | | |
168 | 173 | | |
169 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
170 | 182 | | |
171 | 183 | | |
172 | 184 | | |
173 | 185 | | |
174 | 186 | | |
| 187 | + | |
| 188 | + | |
175 | 189 | | |
176 | 190 | | |
177 | 191 | | |
178 | 192 | | |
179 | 193 | | |
180 | 194 | | |
181 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
182 | 200 | | |
183 | 201 | | |
184 | 202 | | |
185 | 203 | | |
186 | | - | |
187 | | - | |
188 | 204 | | |
189 | 205 | | |
190 | 206 | | |
| |||
232 | 248 | | |
233 | 249 | | |
234 | 250 | | |
235 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
236 | 270 | | |
237 | 271 | | |
238 | 272 | | |
| |||
242 | 276 | | |
243 | 277 | | |
244 | 278 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
255 | 284 | | |
256 | 285 | | |
257 | 286 | | |
| |||
260 | 289 | | |
261 | 290 | | |
262 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
263 | 295 | | |
264 | 296 | | |
265 | 297 | | |
| |||
269 | 301 | | |
270 | 302 | | |
271 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
272 | 307 | | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
28 | | - | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
| |||
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
109 | 122 | | |
110 | 123 | | |
111 | 124 | | |
| |||
337 | 350 | | |
338 | 351 | | |
339 | 352 | | |
340 | | - | |
| 353 | + | |
| 354 | + | |
341 | 355 | | |
342 | 356 | | |
343 | 357 | | |
344 | 358 | | |
345 | 359 | | |
| 360 | + | |
346 | 361 | | |
347 | 362 | | |
348 | 363 | | |
| |||
620 | 635 | | |
621 | 636 | | |
622 | 637 | | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
623 | 652 | | |
624 | 653 | | |
625 | | - | |
| 654 | + | |
| 655 | + | |
626 | 656 | | |
627 | 657 | | |
628 | 658 | | |
629 | 659 | | |
630 | | - | |
| 660 | + | |
631 | 661 | | |
632 | 662 | | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | | - | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
646 | 666 | | |
647 | 667 | | |
648 | | - | |
649 | | - | |
650 | 668 | | |
651 | 669 | | |
652 | 670 | | |
653 | 671 | | |
654 | 672 | | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
0 commit comments