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

File system persistence for sessions #1105

Merged
merged 20 commits into from
Jul 14, 2021
Merged

File system persistence for sessions #1105

merged 20 commits into from
Jul 14, 2021

Conversation

Tyrrrz
Copy link
Contributor

@Tyrrrz Tyrrrz commented Jul 2, 2021

Closes #1096

@Tyrrrz
Copy link
Contributor Author

Tyrrrz commented Jul 5, 2021

Still missing support for special handling of paused sessions (will have to store additional data in the file) and DidCrash handler. But what do you think about the general direction @bruno-garcia?

src/Sentry/GlobalSessionManager.cs Outdated Show resolved Hide resolved
src/Sentry/GlobalSessionManager.cs Show resolved Hide resolved
src/Sentry/GlobalSessionManager.cs Outdated Show resolved Hide resolved
src/Sentry/IJsonSerializable.cs Outdated Show resolved Hide resolved
src/Sentry/SentryOptionsExtensions.cs Show resolved Hide resolved
@Tyrrrz
Copy link
Contributor Author

Tyrrrz commented Jul 9, 2021

@bruno-garcia some significant changes.
I had to change how the pause/resume works so that it's more encapsulated within session manager, which would allow it to take ownership of the file persistence logic. As a result, it now returns multiple updates from ResumeSession(...) back to Hub. Ugly, but I don't think there are better options since GlobalSessionManager does not encapsulate a reference to ISentryClient (although that wouldn't be a horrible idea maybe?).
Evaluating race conditions and thread contention is a nightmare now, too many variables. Part of me just wants to wrap everything in locks.
What do you think?

src/Sentry/GlobalSessionManager.cs Outdated Show resolved Hide resolved
src/Sentry/Internal/Json.cs Show resolved Hide resolved
src/Sentry/GlobalSessionManager.cs Show resolved Hide resolved
@Tyrrrz Tyrrrz marked this pull request as ready for review July 13, 2021 21:22
@codecov-commenter
Copy link

codecov-commenter commented Jul 13, 2021

Codecov Report

Merging #1105 (c8dc470) into main (1b7e3c8) will decrease coverage by 0.32%.
The diff coverage is 72.30%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1105      +/-   ##
==========================================
- Coverage   80.97%   80.64%   -0.33%     
==========================================
  Files         195      197       +2     
  Lines        6422     6582     +160     
  Branches     1417     1452      +35     
==========================================
+ Hits         5200     5308     +108     
- Misses        761      803      +42     
- Partials      461      471      +10     
Impacted Files Coverage Δ
src/Sentry/Internal/Hub.cs 61.61% <29.16%> (-7.74%) ⬇️
src/Sentry/Internal/Http/CachingTransport.cs 78.14% <66.66%> (-0.57%) ⬇️
src/Sentry/SentryOptionsExtensions.cs 71.42% <71.42%> (ø)
src/Sentry/GlobalSessionManager.cs 70.44% <74.43%> (+3.00%) ⬆️
src/Sentry/IJsonSerializable.cs 100.00% <100.00%> (ø)
src/Sentry/Internal/Json.cs 100.00% <100.00%> (ø)
src/Sentry/PersistedSessionUpdate.cs 100.00% <100.00%> (ø)
src/Sentry/SentryOptions.cs 89.24% <100.00%> (+0.06%) ⬆️
src/Sentry/SessionUpdate.cs 93.39% <100.00%> (+0.12%) ⬆️
... and 2 more

Continue to review full report at Codecov.

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

@Tyrrrz Tyrrrz requested a review from bruno-garcia July 13, 2021 21:27
Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

Some small suggestions but LGTM

CHANGELOG.md Outdated Show resolved Hide resolved
src/Sentry/GlobalSessionManager.cs Outdated Show resolved Hide resolved
src/Sentry/GlobalSessionManager.cs Outdated Show resolved Hide resolved
src/Sentry/GlobalSessionManager.cs Show resolved Hide resolved
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.

Cache current session information on disk.
3 participants