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

Add support for Serilog.Formatting.ITextFormatter #998

Merged
merged 5 commits into from
May 19, 2021

Conversation

Genteure
Copy link
Contributor

This feature is needed because sometimes a identifier of some kind (example: user id, task id) is added via Serilog.ILogger.ForContext() so it's not visible in the log message body.
Currently there's no option to control how sentry formats received log events.
Most Serilog sinks that output texts have a Serilog.Formatting.ITextFormatter formatter or string outputTemplate argument so additional information can be added to the result log text.

This pull request is adding more arguments to public methods thus should be considered as a breaking change.

@Genteure Genteure requested a review from bruno-garcia as a code owner May 16, 2021 11:03
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.

Thanks for adding this!
Before we can merge this could you please add a test that uses the TextFormatter?
There's also a sample in the repo: https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.Serilog

And one with ASP.NET Core: https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.Serilog

Would you please also use it in one of the samples to help show its usage?

src/Sentry.Serilog/SentrySinkExtensions.cs Outdated Show resolved Hide resolved
src/Sentry.Serilog/SentrySink.cs Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented May 16, 2021

Codecov Report

Merging #998 (b6f140d) into main (351f264) will decrease coverage by 1.74%.
The diff coverage is 72.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #998      +/-   ##
==========================================
- Coverage   81.26%   79.51%   -1.75%     
==========================================
  Files         184      184              
  Lines        5893     5903      +10     
  Branches     1452     1454       +2     
==========================================
- Hits         4789     4694      -95     
- Misses        689      801     +112     
+ Partials      415      408       -7     
Impacted Files Coverage Δ
src/Sentry.Serilog/SentrySinkExtensions.cs 52.43% <0.00%> (-2.00%) ⬇️
src/Sentry.Serilog/SentrySerilogOptions.cs 100.00% <100.00%> (ø)
src/Sentry.Serilog/SentrySink.cs 82.92% <100.00%> (+1.34%) ⬆️
src/Sentry/PlatformAbstractions/FrameworkInfo.cs 0.00% <0.00%> (-100.00%) ⬇️
...ntry/PlatformAbstractions/RegistryKeyExtensions.cs 0.00% <0.00%> (-100.00%) ⬇️
...Sentry/PlatformAbstractions/FrameworkInfo.NetFx.cs 0.00% <0.00%> (-71.24%) ⬇️
...rmAbstractions/NetFxInstallationsEventProcessor.cs 4.54% <0.00%> (-68.19%) ⬇️
...ntry/Integrations/NetFxInstallationsIntegration.cs 33.33% <0.00%> (-66.67%) ⬇️
...ntry/PlatformAbstractions/FrameworkInstallation.cs 25.00% <0.00%> (-37.50%) ⬇️
src/Sentry/PlatformAbstractions/RuntimeInfo.cs 53.44% <0.00%> (-5.18%) ⬇️
... 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 351f264...b6f140d. Read the comment docs.

Genteure and others added 2 commits May 17, 2021 01:37
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
@Genteure Genteure requested a review from bruno-garcia May 16, 2021 17:45
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.

Looks great!

The only thing is that as a breaking change this should land on our next major.

@Tyrrrz thoughts?

@bruno-garcia
Copy link
Member

Oh @Genteure could you please add a changelog entry?

@Genteure
Copy link
Contributor Author

Sure. Which version should I put this change under? From dangerfile.js I think it should be "Unreleased"?

@bruno-garcia
Copy link
Member

Right, I don't know why it didn't write the comment here but it should be something like

## Unreleased

### Features

- Serilog: Add support for Serilog.Formatting.ITextFormatter [#998](https://github.com/getsentry/sentry-dotnet/pull/998)

@Tyrrrz
Copy link
Contributor

Tyrrrz commented May 17, 2021

Looks good, I only have one nit

@bruno-garcia bruno-garcia added this to the 4.0.0 milestone May 18, 2021
@Tyrrrz Tyrrrz enabled auto-merge (squash) May 19, 2021 08:10
@Tyrrrz Tyrrrz merged commit 984b210 into getsentry:main May 19, 2021
@Tyrrrz
Copy link
Contributor

Tyrrrz commented May 19, 2021

Thanks @Genteure 🎉

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.

4 participants