Added non-initialising overload to SerilogSinkExtensions#2928
Added non-initialising overload to SerilogSinkExtensions#2928bitsandfoxes merged 7 commits intomainfrom
Conversation
There was a problem hiding this comment.
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: |
bitsandfoxes
left a comment
There was a problem hiding this comment.
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.InitorUsingSentryand then you wire up Serilog to use Sentry via theSentrySinkExtensions.Sentryextension 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.Sentryoverrides and added another.The first override has been changed such that the
dsnparameter 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
dsnparameter... 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.