getsentry / getsentry/sentry-dotnet

Allow for optional separation into services.AddSentry and app.UseSentry

Open
#3,139 4 comments 2 reactions 0 assignees View on GitHub
.NET Feature
Dominant language
C#
Stars
770
Forks
248
Avg merge
3d 4h
Merged PRs (30d)
49

Description

### Problem Statement

Currently, the SDK combines config and enabling into a single `webBuilder.UseSentry` method.

This is contrary to the convention of having separate `services.AddSentry` and `app.UseSentry` methods, which allows for more control.

Adding these two methods (in addition to the current single "convenience" method) would make it at lot easier to do things like this:

```
if (app.Environment.isProduction())
{
app.UseSentry():
}
```

---

Additionally, I would suggest that `AddSentry` should DI register an ISentry service for developers to use instead of the `SentrySdk` static class.
(For backcompat reasons, it would probably make sense to offer both the existing \`SentrySdk' static class and the new ISentry service, as wrappers around shared internal implementation.)

Adding an ISentry service would better align the Sentry experience with the modern [ASP.NET]() Core DI-driven conventions.

Cheers!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.