Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make Scope.span fully thread safe #4519

Merged
merged 3 commits into from
Nov 12, 2024
Merged

Conversation

philipphofmann
Copy link
Member

📜 Description

Setting the span on the scope and useSpan were thread safe, but not setSpan. This is fixed now.

💡 Motivation and Context

This came up while investigating #4513.

💚 How did you test it?

Unit tests.

📝 Checklist

You have to check all boxes before merging:

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Setting the span on the scope and useSpan were thread safe, but not
setSpan. This is fixed now.
Copy link

github-actions bot commented Nov 8, 2024

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1232.70 ms 1235.96 ms 3.25 ms
Size 22.30 KiB 730.03 KiB 707.73 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
6bc5ae5 1207.23 ms 1216.66 ms 9.43 ms
65e48e0 1223.68 ms 1238.96 ms 15.28 ms
5616e0a 1224.12 ms 1249.86 ms 25.74 ms
6943de0 1230.02 ms 1235.32 ms 5.30 ms
3db3e35 1233.52 ms 1256.43 ms 22.90 ms
aea5987 1223.84 ms 1244.39 ms 20.55 ms
ed49f0c 1245.67 ms 1261.15 ms 15.48 ms
20a828b 1211.33 ms 1228.00 ms 16.67 ms
af1f4dd 1225.39 ms 1245.48 ms 20.09 ms
50bb751 1234.10 ms 1248.29 ms 14.19 ms

App size

Revision Plain With Sentry Diff
6bc5ae5 20.76 KiB 401.39 KiB 380.63 KiB
65e48e0 21.90 KiB 708.34 KiB 686.44 KiB
5616e0a 22.85 KiB 407.44 KiB 384.59 KiB
6943de0 20.76 KiB 393.33 KiB 372.57 KiB
3db3e35 21.58 KiB 419.21 KiB 397.63 KiB
aea5987 21.58 KiB 418.13 KiB 396.54 KiB
ed49f0c 21.58 KiB 632.13 KiB 610.55 KiB
20a828b 21.58 KiB 670.99 KiB 649.41 KiB
af1f4dd 22.85 KiB 414.71 KiB 391.86 KiB
50bb751 21.58 KiB 417.86 KiB 396.27 KiB

Previous results on branch: fix/scope-get-span-lock

Startup times

Revision Plain With Sentry Diff
582e4c8 1209.23 ms 1222.73 ms 13.51 ms

App size

Revision Plain With Sentry Diff
582e4c8 21.90 KiB 727.73 KiB 705.82 KiB

Copy link

codecov bot commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.535%. Comparing base (4509e9c) to head (0da7052).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #4519       +/-   ##
=============================================
+ Coverage   91.513%   91.535%   +0.022%     
=============================================
  Files          615       615               
  Lines        69460     69489       +29     
  Branches     24896     24921       +25     
=============================================
+ Hits         63565     63607       +42     
+ Misses        5802      5789       -13     
  Partials        93        93               
Files with missing lines Coverage Δ
Sources/Sentry/SentryScope.m 96.859% <100.000%> (+0.015%) ⬆️
Tests/SentryTests/SentryScopeSwiftTests.swift 99.056% <100.000%> (+0.024%) ⬆️

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4509e9c...0da7052. Read the comment docs.

Copy link
Contributor

@brustolin brustolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sources/Sentry/SentryScope.m Show resolved Hide resolved
@brustolin
Copy link
Contributor

Also I dont think we need useSpan anymore, we should mark it as deprecated.

@philipphofmann
Copy link
Member Author

Also I dont think we need useSpan anymore, we should mark it as deprecated.

We still use useSpan in multiple places in the SDK. We can consider removing it in the next version.

@philipphofmann philipphofmann merged commit fecbc76 into main Nov 12, 2024
66 checks passed
@philipphofmann philipphofmann deleted the fix/scope-get-span-lock branch November 12, 2024 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants