Skip to content

Issues/questions migrating from Raven with ASP.NET MVC #197

@winzig

Description

@winzig

For the most basic scenario ("I just want to log .NET exceptions to Sentry"), the documentation is adequate, and the .UseSentry() method is easy to use. But I'm trying to migrate from my original use of the Raven .NET SDK, and I keep running into things I can't find documented.

So in the context of ASP.NET Core MVC, I ask these questions:

How do we modify the scope for the current HttpRequest?

Previously in my custom Sentry logging, I would create a SentryEvent, including modifying the fingerprint, setting the tags, etc. It seems like this is done on Scopes now, but I cannot figure out how to access the per-request Scope. All the sample code I'm seeing just calls into SentrySdk directly.

This doc talks about the exact issue I'm facing — what's the best way to access the current Scope for the current request in ASP.NET MVC — except it doesn't actually explain how to do it. It just links to some sample code, but I am not seeing this in the code.

What's the preferred way of modifying User data before the event is sent to Sentry?

This page only talks about Scopes, but I have yet to find documentation which explains how to access the per-request scope that I presume Sentry has available somewhere.

I see IUserFactory, which seems similar to what we use in the old SDK, SentryUserFactory. But it's unclear where to register that factory in the new SDK, assuming that's even the preferred way to modify User properties before logging an event.

What are ISentryEventExceptionProcessor and ISentryEventProcessor?

In the MVC sample code, I see references to adding implementations of these as singletons and transients, but can't find where these classes are documented:

// Register as many ISentryEventExceptionProcessor as you need. They ALL get called.
services.AddSingleton<ISentryEventExceptionProcessor, SpecialExceptionProcessor>();

// You can also register as many ISentryEventProcessor as you need.
services.AddTransient<ISentryEventProcessor, ExampleEventProcessor>();

How do I do handle exceptions that may be encountered while logging to Sentry?

Previously there was an ErrorOnCapture on RavenClient, but not seeing anything like that in SentryClient.

Is SentryClient thread-safe?

With RavenClient we would keep a static singleton around in scenarios where we wanted to log an exception outside of a typical HttpContext/request. Is this the best way to handle these scenarios with the new SDK?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions