Skip to content

log through serialization#1388

Merged
bruno-garcia merged 11 commits intomainfrom
ref/serialization-logging
Dec 15, 2021
Merged

log through serialization#1388
bruno-garcia merged 11 commits intomainfrom
ref/serialization-logging

Conversation

@bruno-garcia
Copy link
Member

@bruno-garcia bruno-garcia commented Dec 14, 2021

Resolves #946


var persistedSessionUpdate = new PersistedSessionUpdate(update, pauseTimestamp);
persistedSessionUpdate.WriteToFile(filePath);
persistedSessionUpdate.WriteToFile(filePath, _options.DiagnosticLogger!);
Copy link
Member Author

Choose a reason for hiding this comment

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

We'll need to remove this !. No other way but to make it nullable I believe

// The only location in the protocol we allow dynamic objects are Extra and Contexts
// In the event of an instance that can't be serialized, we don't want to throw away a whole event
// so we'll suppress issues here.
logger?.LogError("Failed to serialize object for property {0}", e, propertyName);
Copy link
Member Author

Choose a reason for hiding this comment

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

We could use the same approach @SimonCropp took and if logger is null) { throw;

Copy link
Collaborator

Choose a reason for hiding this comment

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

I went with catch Exception ex when (logger != null)

@codecov-commenter
Copy link

Codecov Report

Merging #1388 (0ed95ba) into main (2e6f9c7) will decrease coverage by 1.33%.
The diff coverage is 94.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1388      +/-   ##
==========================================
- Coverage   82.73%   81.40%   -1.34%     
==========================================
  Files         215      215              
  Lines        7165     7173       +8     
  Branches     1410     1411       +1     
==========================================
- Hits         5928     5839      -89     
- Misses        802      908     +106     
+ Partials      435      426       -9     
Impacted Files Coverage Δ
src/Sentry/Breadcrumb.cs 93.47% <ø> (ø)
src/Sentry/Envelopes/StreamSerializable.cs 100.00% <ø> (ø)
src/Sentry/Package.cs 75.00% <ø> (ø)
src/Sentry/Protocol/App.cs 95.55% <ø> (ø)
src/Sentry/Protocol/Browser.cs 93.75% <ø> (ø)
src/Sentry/Protocol/Device.cs 82.50% <ø> (ø)
src/Sentry/Protocol/Gpu.cs 82.35% <ø> (ø)
src/Sentry/Protocol/OperatingSystem.cs 85.00% <ø> (ø)
src/Sentry/Protocol/Runtime.cs 86.66% <ø> (ø)
src/Sentry/User.cs 85.18% <ø> (ø)
... and 38 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 2e6f9c7...0ed95ba. Read the comment docs.

@lucas-zimerman
Copy link
Collaborator

Ping @bruno-garcia for review since he's the PR owner :D

@bruno-garcia
Copy link
Member Author

Thank you @lucas-zimerman for fixing this PR

writer.WritePropertyName(propertyName);
writer.WriteDynamicValue(value, logger);
}
catch (Exception e) when (logger != null)
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
catch (Exception e) when (logger != null)
catch (Exception e) when (logger is not null)

@bruno-garcia bruno-garcia merged commit efdb15e into main Dec 15, 2021
@bruno-garcia bruno-garcia deleted the ref/serialization-logging branch December 15, 2021 17:25
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.

Exception serializing envelope with WriteDynamicValue

5 participants