-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Serilog + WorkerService + IHostBuilder #1001
Comments
@bruno-garcia thoughts? Would we add another package or shoehorn this new |
Thanks for taking the time to look at this. This came up a while ago (#190) and it's a constant ask. It's ideal that we keep a single entrypoint (that can do N things, for example as you mentioned DI, Logging and also decorating the request pipeline). That's because the goal is for us to have as little friction to add the SDK as possible. For that reason I believe it's best we have So docs for ASP.NET Core should continue to be: Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseSentry()
webBuilder.UseStartup<Startup>();
}); As opposed to: Host.CreateDefaultBuilder(args)
.UseSentry()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseSentry()
webBuilder.UseStartup<Startup>();
}); We could then have docs for worker projects that rely only on
I believe that makes sense. We don't need to have a 1:1 parity to the ASP.NET packages. Today Once again thanks a lot for doing this analysis and for offering to contribute with a PR. I always suggest folks to open a quick and dirty draft PR without any tests or docs (CI doesn't need to pass) to discuss things before putting too much effort. It can help us talk about the design before the final touches happen. |
Also maybe related to (or even duplicate of?) #190 |
Ok, thank you for the feedback. |
Blocked on #190. Keeping this open for followup after that is done. |
Since we decided not to implement #190, maybe this also needs to be closed? |
I've been searching for quite a while how to make Serilog and Sentry work together in a WorkerService environment (.net core > 3)
I've come to the conclusion that this is not easily done / possible right now due to some limitation:
Known issue:
IHostBuilder
extension method for sentryUnable to 'hack' together what I need by using internals / copy pasting
IApplicationBuilder
is marked internal (sentry-dotnet/src/Sentry.AspNetCore/ApplicationBuilderExtensions.cs
Line 25 in 351f264
IServiceCollectionExtension
method is marked internal (sentry-dotnet/src/Sentry.AspNetCore/Extensions/DependencyInjection/ServiceCollectionExtensions.cs
Line 14 in 351f264
Work around
The current 'work-around' I have is using the Serilog sink and let it initialise the SDK, and add the following in
ConfigureServices
:WARNING This is not production tested, just to make it work locally
However this way you lose the extensibility of Sentry together with DI
There might be other ways, in which case feel free to add them :)
Proposal
First an observation,
IWebHostBuilder
on a high level does 2 things (i know it's a bit reductive):Proposed changes:
IHostBuilder
extension methodUseSentryCore
that handles (1)IWebHostBuilder
extension methodUseSentryWeb
that handles (2)IWebHostBuilder
extension methodUseSentry
for backwards compatibilityAnalysis
This is after a short, preliminary & quick swoop through the code base:
Split following classes into core and web (or add methods to support them)
I might be able to free some time for a PR once this proposal is finalised
The text was updated successfully, but these errors were encountered: