ref: pass snapshotted request to addBaggageHeader - #8386
Draft
itaybre wants to merge 1 commit into
Draft
Conversation
The caller (SentryNetworkTracker) already snapshots sessionTask.currentRequest before the @synchronized block. Pass that snapshot as a parameter instead of re-reading the volatile property inside SentryTracePropagation. Since the passed-in request may be a different object than the task's currentRequest (e.g. due to Swift bridging), always call setCurrentRequest: after adding headers to ensure the task reflects the change. Follows up on #8058.
Contributor
🚨 Detected changes in high risk code 🚨High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:
|
📲 Install BuildsiOS
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 31e3b65 | 1225.70 ms | 1246.98 ms | 21.28 ms |
| 6b08499 | 1231.61 ms | 1241.90 ms | 10.29 ms |
| 655e96d | 1217.63 ms | 1258.34 ms | 40.72 ms |
| 4c437ea | 1241.63 ms | 1266.20 ms | 24.57 ms |
| 466b8d9 | 1227.17 ms | 1252.85 ms | 25.68 ms |
| 994f7a3 | 1208.71 ms | 1240.54 ms | 31.83 ms |
| 095fdf6 | 1218.73 ms | 1252.79 ms | 34.06 ms |
| 274f59c | 1223.62 ms | 1258.13 ms | 34.51 ms |
| 4a1cc18 | 1218.61 ms | 1251.19 ms | 32.58 ms |
| 22550bf | 1223.24 ms | 1259.38 ms | 36.14 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 31e3b65 | 24.14 KiB | 1.23 MiB | 1.21 MiB |
| 6b08499 | 24.14 KiB | 1.15 MiB | 1.13 MiB |
| 655e96d | 24.14 KiB | 1.18 MiB | 1.16 MiB |
| 4c437ea | 24.14 KiB | 1.18 MiB | 1.15 MiB |
| 466b8d9 | 24.14 KiB | 1.18 MiB | 1.15 MiB |
| 994f7a3 | 24.14 KiB | 1.15 MiB | 1.13 MiB |
| 095fdf6 | 24.14 KiB | 1.22 MiB | 1.20 MiB |
| 274f59c | 24.14 KiB | 1.17 MiB | 1.15 MiB |
| 4a1cc18 | 24.14 KiB | 1.22 MiB | 1.20 MiB |
| 22550bf | 24.14 KiB | 1.23 MiB | 1.20 MiB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
currentRequestas a parameter toSentryTracePropagation.addBaggageHeaderinstead of re-reading the volatile property inside the methodsetCurrentRequest:after adding headers, since the passed-in request may be a different object than the task'scurrentRequest(e.g. due to Swift/ObjC bridging)URLSessionDownloadTaskMockto properly supportsetCurrentRequest:(matchingURLSessionDataTaskMock), fixing the Swift↔ObjC bridging issue in testsFollows up on #8058 (review comment).
#skip-changelog
Test plan
SentryTracePropagationTests— all 11 tests passSentryNetworkTrackerTests— all 75 tests passmake build-iossucceeds