sentry-dotnet: Callback not called when sentry is not registered

Package

Sentry

.NET Flavor

.NET

.NET Version

6.0.0

OS

Any (not platform specific)

SDK Version

3.33.1

Self-Hosted Sentry Version

No response

Steps to Reproduce

We have some internal nuget packages that integrate with Sentry if sentry is registered. We currently do something like:

hub = serviceProvider.GetService<IHub>() ?? HubAdapter.Instance;

Now when calling WithScopeAsync when Sentry has not been registered in the .net core app, the code is not called:

await _hub.WithScopeAsync(async scope =>
    ... //This code is not called if sentry is not registered
);

I tracked it down to this line of code: https://github.com/getsentry/sentry-dotnet/blob/410b30d2ce0c4db93c050778249b0d812aff089c/src/Sentry/SentryScopeManagerExtensions.cs#L52

Expected Result

Code is being called even if sentry is not registered

Actual Result

Code is not being called

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 18 (2 by maintainers)

Most upvoted comments

Thanks for the tips, I’ll have a look.

I guess as the original issue is ‘resolved’ you can go ahead and close this ticket.

I would still be awesome if the callback was still called, but for now we’ll work around that