Skip to content

ref: pass snapshotted request to addBaggageHeader - #8386

Draft
itaybre wants to merge 1 commit into
mainfrom
ref/pass-request-to-trace-propagation
Draft

ref: pass snapshotted request to addBaggageHeader#8386
itaybre wants to merge 1 commit into
mainfrom
ref/pass-request-to-trace-propagation

Conversation

@itaybre

@itaybre itaybre commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Pass the already-snapshotted currentRequest as a parameter to SentryTracePropagation.addBaggageHeader instead of re-reading the volatile property inside the method
  • Simplify the header-injection logic: always call setCurrentRequest: after adding headers, since the passed-in request may be a different object than the task's currentRequest (e.g. due to Swift/ObjC bridging)
  • Update URLSessionDownloadTaskMock to properly support setCurrentRequest: (matching URLSessionDataTaskMock), fixing the Swift↔ObjC bridging issue in tests

Follows up on #8058 (review comment).

#skip-changelog

Test plan

  • SentryTracePropagationTests — all 11 tests pass
  • SentryNetworkTrackerTests — all 75 tests pass
  • make build-ios succeeds

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.
@github-actions

Copy link
Copy Markdown
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:

  • Sources/Sentry/SentryNetworkTracker.m

@itaybre itaybre added the ready-to-merge (deprecated) Use run-full-ci instead. label Jul 10, 2026
@sentry

sentry Bot commented Jul 10, 2026

Copy link
Copy Markdown

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.21.0 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1235.00 ms 1263.96 ms 28.96 ms
Size 24.14 KiB 1.23 MiB 1.21 MiB

Baseline results on branch: main

Startup times

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge (deprecated) Use run-full-ci instead.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant