-
-
Notifications
You must be signed in to change notification settings - Fork 230
SentryEvent class does not contain a property that stores the scoped ServiceProvider #488
Description
Please mark the type framework used:
- ASP.NET MVC
- ASP.NET Web API (OWIN)
- [X ] ASP.NET Core
- WPF
- WinForms
- Xamarin
- Other:
Please mark the type of the runtime used:
- .NET Framework
- Mono
- [X ] .NET Core
- Version: 3.1
Please mark the NuGet packages used:
- Sentry
- Sentry.Serilog
- Sentry.NLog
- Sentry.Log4Net
- Sentry.Extensions.Logging
- [X ] Sentry.AspNetCore
- Version: 2.1.6
Hello, i am trying to use the Sentry.AspNetCore for logging exceptions. But right now i'm facing a issue, i'm trying to put informations in my tags by modyfing the BeforeSend property and the problem is that the SentryEvent class does not contain a property for the scoped serviceProvider that contains the informations that i needed in the first place.
options.BeforeSend = sentryEvent => { sentryEvent.ServiceProvider; return sentryEvent; };
I believe that we are able to get the service provider by changing the InvokeAsync method inside the SentryMiddleware class with the following change:
void CaptureException(Exception e)
{
var evt = new SentryEvent(e);
// ServiceProvider is the new property to be implemented that is responsible for storing the IServiceProvider
evt.ServiceProvider = context.RequestServices;
_logger?.LogTrace("Sending event '{SentryEvent}' to Sentry.", evt);
var id = hub.CaptureEvent(evt);
_logger?.LogInformation("Event '{id}' queued.", id);
}
Is this a valid change? Is there another way of doing it?