-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
Added non-initialising overload to SerilogSinkExtensions #2928
Conversation
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.
There's a ton of refactoring mixed with the change in behavior which makes code review really difficult. Ideally try to keep refactoring to a minimum in PRs that are fixing or adding a feature. PRs done just for refactoring are much simpler to review
https://www.codewithjason.com/dont-mix-refactorings-behavior-changes/
I removed almost all the refactoring... the only one I left in there is to remove redundant default values for I put the refactoring in a separate PR, in case we want to consider it: |
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 this! LGTM!
Resolves #2884
Problem statement
Previously configuring Sentry to work with Serilog was extremely error prone. If you initialized Sentry using
SentrySdk.Init
orUsingSentry
and then you wire up Serilog to use Sentry via theSentrySinkExtensions.Sentry
extension method we provide, without supplying any parameters to that method, you get an exception at runtime because it tries to initialize the SDK without a DSN 😢A simple example is:
Whilst it looks like that should work, the initialization code in the call to
WriteTo.Sentry()
would be executed before the initialization code in the call toUseSentry
(where a DSN is actually provided) and the user would get an error that was not obvious to resolve.Solution
We have changed one of the
WriteTo.Sentry
overrides and added another.The first override has been changed such that the
dsn
parameter is no longer optional. This is the override that should be used when users do want to initialize the Sentry SDK at the same time as setting up a Sentry Serilog Sink.The second override doesn't take any
dsn
parameter... indeed it only accepts the limited set of arguments concerned with configuring the Sentry Serilog Sink itself. This is the variant that will be used if no arguments are supplied. Thus the sample code above will work as expected.