-
-
Notifications
You must be signed in to change notification settings - Fork 372
feat: Add attributes data to SentryScope
#6830
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
base: main
Are you sure you want to change the base?
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6830 +/- ##
=============================================
+ Coverage 84.918% 84.920% +0.002%
=============================================
Files 453 448 -5
Lines 27630 27541 -89
Branches 12135 12051 -84
=============================================
- Hits 23463 23388 -75
+ Misses 4122 3866 -256
- Partials 45 287 +242
... and 42 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| effeafa | 1225.88 ms | 1249.78 ms | 23.90 ms |
| 483cc24 | 1218.00 ms | 1242.59 ms | 24.59 ms |
| c5d3752 | 1221.51 ms | 1245.63 ms | 24.11 ms |
| 27e7514 | 1229.47 ms | 1245.60 ms | 16.13 ms |
| afaa522 | 1234.71 ms | 1256.19 ms | 21.48 ms |
| 7bd90de | 1233.48 ms | 1249.47 ms | 15.99 ms |
| e5773c1 | 1235.10 ms | 1264.15 ms | 29.04 ms |
| 42a95d5 | 1206.00 ms | 1224.26 ms | 18.26 ms |
| 2c889f6 | 1206.35 ms | 1233.29 ms | 26.94 ms |
| f9270f9 | 1227.90 ms | 1253.24 ms | 25.34 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| effeafa | 23.74 KiB | 926.64 KiB | 902.89 KiB |
| 483cc24 | 24.14 KiB | 1.01 MiB | 1010.98 KiB |
| c5d3752 | 24.14 KiB | 1.01 MiB | 1013.49 KiB |
| 27e7514 | 23.75 KiB | 919.69 KiB | 895.94 KiB |
| afaa522 | 23.74 KiB | 996.91 KiB | 973.17 KiB |
| 7bd90de | 23.75 KiB | 933.33 KiB | 909.58 KiB |
| e5773c1 | 23.75 KiB | 1.00 MiB | 1005.08 KiB |
| 42a95d5 | 23.75 KiB | 906.08 KiB | 882.33 KiB |
| 2c889f6 | 23.75 KiB | 1010.42 KiB | 986.67 KiB |
| f9270f9 | 24.14 KiB | 1.01 MiB | 1012.18 KiB |
Previous results on branch: itay/scopes_set_attributes_logs
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| f2aa2be | 1218.04 ms | 1253.26 ms | 35.21 ms |
| 5456d19 | 1221.64 ms | 1256.84 ms | 35.20 ms |
| 263d753 | 1218.82 ms | 1250.37 ms | 31.55 ms |
| 668b816 | 1210.54 ms | 1247.96 ms | 37.42 ms |
| 4f7825f | 1229.96 ms | 1266.36 ms | 36.40 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| f2aa2be | 24.14 KiB | 1.01 MiB | 1015.08 KiB |
| 5456d19 | 24.14 KiB | 1.02 MiB | 1016.14 KiB |
| 263d753 | 24.14 KiB | 1.01 MiB | 1013.78 KiB |
| 668b816 | 24.14 KiB | 1.01 MiB | 1015.68 KiB |
| 4f7825f | 24.15 KiB | 1.01 MiB | 1015.11 KiB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Attributes not cleared in clear method
The clear method was not updated to reset the attributesDictionary. As a result, scope.attributes persist on the scope object even after scope.clear() is explicitly called.
Sources/Sentry/SentryScope.m#L170-L203
sentry-cocoa/Sources/Sentry/SentryScope.m
Lines 170 to 203 in 6566e2d
| return nil; | |
| } | |
| - (void)clear | |
| { | |
| // As we need to synchronize the accesses of the arrays and dictionaries and we use the | |
| // references instead of self we remove all objects instead of creating new instances. Removing | |
| // all objects is usually O(n). This is acceptable as we don't expect a huge amount of elements | |
| // in the arrays or dictionaries, that would slow down the performance. | |
| [self clearBreadcrumbs]; | |
| @synchronized(_tagDictionary) { | |
| [_tagDictionary removeAllObjects]; | |
| } | |
| @synchronized(_extraDictionary) { | |
| [_extraDictionary removeAllObjects]; | |
| } | |
| @synchronized(_contextDictionary) { | |
| [_contextDictionary removeAllObjects]; | |
| } | |
| @synchronized(_fingerprintArray) { | |
| [_fingerprintArray removeAllObjects]; | |
| } | |
| [self clearAttachments]; | |
| @synchronized(_spanLock) { | |
| _span = nil; | |
| } | |
| self.userObject = nil; | |
| self.distString = nil; | |
| self.environmentString = nil; | |
| self.levelEnum = kSentryLevelNone; | |
| for (id<SentryScopeObserver> observer in self.observers) { | |
| [observer clear]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also update the SentryScope+Equality.m test file.
Currently units are not supported since Logs don't support them (yet).
Yes, but please double-check that we can add these without a breaking change. I think we should be good because we will simply add method overloads, but it is still worth checking if that works.
We should merge this PR including #6834 to main cause otherwise the attributes are useless. Thanks for splitting this up into two PRs.
We can just add a new method with the unit parameter, I initially had it like that until I realized we cannot use the unit at this moment. I am waiting to merge this one and then the other PR. |
philipphofmann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I found one potential bug. Almost LGTM
Adds
setAttributeandremoveAttributetoSentryScopeas per https://develop.sentry.dev/sdk/telemetry/scopes/#scope-methodsThese attributes will be used for logs in a following PR.
Currently units are not supported since Logs don't support them (yet).
Closes #6835