You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to add Bugsnag to a reverse proxy project (.NET Core 3.1). Since this is not a classic MVC/WebAPI project, there are no controllers, and most of the code runs in a static context. The Bugsnag.AspNet.Core package adds the Bugsnag client as scoped service, which makes it difficult to use in static contexts (from singleton services for example).
Describe the solution you'd like
Be able to register Bugsnag client as singleton service and use IHttpContextAccessor to access request information where needed.
Describe alternatives you've considered
Manually setup Bugsnag without the Bugsnag.AspNet.Core package - not great for me because I would like Bugsnag integration to be as easy as possible in all of our projects.
Create and publish my own package - this will probably be my temporary solution, eventually I would be happy to contribute my work back to this project.
Update - I created a package where the only change is adding Bugsnag.IClient as a singleton instead of a scoped service, and looks like everything just works.
The text was updated successfully, but these errors were encountered:
Thanks for raising this. we will look into this when we can.
For now, it sounds like you have it working as you need it to, so by all means stick with that approach.
Another similar use case would be using Bugsnag inside service registered as IHostedService. Since IHostedService is registered as singleton it is also not possible to use scoped Bugsnag inside of it.
Hi @aycron-dev, You're correct, there isn't a way to do that currently since the Bugsnag client is scoped to the lifetime of a single request. We're going to look into adding support for registering Bugsnag as a singleton when priorities allow.
Description
I would like to add Bugsnag to a reverse proxy project (.NET Core 3.1). Since this is not a classic MVC/WebAPI project, there are no controllers, and most of the code runs in a static context. The
Bugsnag.AspNet.Core
package adds the Bugsnag client as scoped service, which makes it difficult to use in static contexts (from singleton services for example).Describe the solution you'd like
Be able to register Bugsnag client as singleton service and use
IHttpContextAccessor
to access request information where needed.Describe alternatives you've considered
Bugsnag.AspNet.Core
package - not great for me because I would like Bugsnag integration to be as easy as possible in all of our projects.Update - I created a package where the only change is adding
Bugsnag.IClient
as a singleton instead of a scoped service, and looks like everything just works.The text was updated successfully, but these errors were encountered: