-
-
Notifications
You must be signed in to change notification settings - Fork 334
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
feat: Close session for unhandled error #3091
Conversation
This reverts commit ce4236e.
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3091 +/- ##
=============================================
+ Coverage 88.958% 88.960% +0.001%
=============================================
Files 495 495
Lines 53464 53545 +81
Branches 19139 19164 +25
=============================================
+ Hits 47561 47634 +73
- Misses 4944 4950 +6
- Partials 959 961 +2
... and 7 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
e84bc3f | 1201.49 ms | 1232.82 ms | 31.33 ms |
407ff99 | 1225.49 ms | 1232.88 ms | 7.39 ms |
9faf217 | 1268.86 ms | 1274.82 ms | 5.96 ms |
15b8c61 | 1223.16 ms | 1244.83 ms | 21.67 ms |
43aa39d | 1239.16 ms | 1270.42 ms | 31.26 ms |
60dd0f5 | 1212.24 ms | 1240.82 ms | 28.58 ms |
f0737f6 | 1220.43 ms | 1236.44 ms | 16.01 ms |
f938d24 | 1223.26 ms | 1242.12 ms | 18.86 ms |
b2f82fa | 1237.78 ms | 1256.02 ms | 18.24 ms |
25a5e8b | 1249.18 ms | 1268.42 ms | 19.24 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
e84bc3f | 20.76 KiB | 434.72 KiB | 413.96 KiB |
407ff99 | 20.76 KiB | 427.87 KiB | 407.10 KiB |
9faf217 | 20.76 KiB | 419.70 KiB | 398.94 KiB |
15b8c61 | 20.76 KiB | 419.67 KiB | 398.91 KiB |
43aa39d | 20.76 KiB | 432.82 KiB | 412.06 KiB |
60dd0f5 | 20.76 KiB | 393.37 KiB | 372.61 KiB |
f0737f6 | 20.76 KiB | 437.12 KiB | 416.36 KiB |
f938d24 | 20.76 KiB | 434.88 KiB | 414.12 KiB |
b2f82fa | 20.76 KiB | 419.62 KiB | 398.86 KiB |
25a5e8b | 20.76 KiB | 436.33 KiB | 415.57 KiB |
Previous results on branch: feat/closesession-forerror
Startup times
Revision | Plain | With Sentry | Diff |
---|---|---|---|
7eae871 | 1223.65 ms | 1226.14 ms | 2.49 ms |
8541ffe | 1228.92 ms | 1237.72 ms | 8.80 ms |
3bd1370 | 1226.51 ms | 1236.50 ms | 9.99 ms |
b267779 | 1196.93 ms | 1239.13 ms | 42.19 ms |
80127d9 | 1219.98 ms | 1236.58 ms | 16.60 ms |
ef9f754 | 1252.96 ms | 1259.38 ms | 6.42 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
7eae871 | 20.76 KiB | 393.68 KiB | 372.92 KiB |
8541ffe | 20.76 KiB | 393.74 KiB | 372.98 KiB |
3bd1370 | 20.76 KiB | 393.74 KiB | 372.98 KiB |
b267779 | 20.76 KiB | 393.70 KiB | 372.94 KiB |
80127d9 | 20.76 KiB | 393.68 KiB | 372.92 KiB |
ef9f754 | 20.76 KiB | 393.70 KiB | 372.94 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.
Thanks for doing this @brustolin.
Sources/Sentry/SentryHub.m
Outdated
[currentSession endSessionCrashedWithTimestamp:[_currentDateProvider date]]; | ||
|
||
_session = [[SentrySession alloc] initWithReleaseName:_client.options.releaseName]; | ||
_session.environment = _client.options.environment; | ||
[self.scope applyToSession:_session]; |
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.
h
: That's not how we safely end and start a new session. I think we should call the following instead.
[self endSessionWithTimestamp:[_currentDateProvider date]];
[hub startSession];
As we also do in the session tracker
sentry-cocoa/Sources/Sentry/SentrySessionTracker.m
Lines 173 to 174 in 60dd0f5
[hub endSessionWithTimestamp:self.lastInForeground]; | |
[hub startSession]; |
Or am I missing something?
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.
Maybe I'm missing something, but this is what I get:
currentSession
is a clone of the current session, If a callself endSessionWithTimestamp
this will not endcurrentSession
.- If I end it before cloning it I cannot clone it.
- By calling
[hub endSession]
the session is immediately captured, but here, the session was being sent in the same envelope. - By calling
startSession
the last session is also capture, which would duplicate the capture
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.
Okay, then what I proposed doesn't seem correct. Your solution definitely needs a lock with @synchronized(_sessionLock)
when creating the new session, you need to handle _errorsBeforeSession
, you need to handle the edge case when there is no releaseName, and you need to store the new session and also capture the new session. Similar to what startSession
does. I think it would be better to maybe refacrot startSession
so you can also use it here.
Furthermore, I think it would make sense to not increment the session error when the event is unhandled. We should just mark it as crashed.
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, take a look at the new approach.
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.
That should work now 👍
Sources/Sentry/SentryHub.m
Outdated
} | ||
if (!handled) { | ||
[currentSession endSessionCrashedWithTimestamp:[_currentDateProvider date]]; | ||
// Setting _session to nil so starSession dont capture it again |
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.
That comment is important, thanks 😃
Co-authored-by: Philipp Hofmann <[email protected]>
📜 Description
Closes session as crashed for hybrids SDK when a new envelope with unhandled crashed event is captured, and start a new session.
💡 Motivation and Context
closes #2593
💚 How did you test it?
📝 Checklist
You have to check all boxes before merging:
sendDefaultPII
is enabled.#skip-changelog