getsentry / getsentry/sentry-dotnet

Don't initialise the Sdk from logging integrations

Open
#5,245 13 comments 0 reactions 0 assignees View on GitHub
.NET Breaking Change Logs Next Major Task
Dominant language
C#
Stars
770
Forks
248
Avg merge
3d 4h
Merged PRs (30d)
49

Description

### Description

[This](https://github.com/getsentry/sentry-dotnet/pull/5176#discussion_r3258518601) and [this](https://github.com/getsentry/sentry-dotnet/discussions/5249) and [this](https://github.com/getsentry/sentry-dotnet/discussions/5249#discussioncomment-17055425) are just three examples in the last two weeks of many many conversations we've had about this issue over the years. It's very confusing to SDK users and even trips us up as maintainers on occasion.

Currently you can initialise Sentry:
1. Via integrations like our Maui or Asp.Net Core integration that support a certain app type/framework
2. Via the static SentrySdk.Init
3. Via one of our logging integrations

The trouble is that the logging integrations are frequently used in conjunction with one of the first two types and then you have to tell the logging integration: Yes do send logs to Sentry, but no do not initialise the Sentry SDK (it's already been initialised).

Initialisation via the logging integrations was added so that if someone is only using the logging integration (e.g. in a Console app) they don't need to call SentrySdk.Init... it saves them a method call at startup.

Given the amount of confusion this causes, I think we should consider changing this so the logging integrations only configure the sink or whatever and the SDK always has to be initialised separately via 1 or 2.

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.