Callback not called when sentry is not registered
See original GitHub issuePackage
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
Issue Analytics
- State:
- Created 3 months ago
- Comments:18 (2 by maintainers)
Top Results From Across the Web
Filtering for Spring - Java
Filtering Error Events. Configure your SDK to filter error events by using the beforeSend callback method and configuring, enabling, or disabling integrations.
Read more >Airflow Not Sending Errors to Sentry Automatically
(I am confident that the sentry_dsn value works, as our code has custom code that we use in failure callbacks that does send...
Read more >Surpressing issues from going to Sentry
I would like to block a few events from going to Sentry using the before_send callback, however the events kept on showing on...
Read more >Sentry in Nova no always propagating correctly
The proposed changes allow the user to specify a callback to report Nova's errors to services like Sentry, Bugsnag, etc. Copy Nova::report(function ($exception) ......
Read more >Unified API - Sentry Developer Documentation
In this case, certain callbacks, such as configure_scope or event processors, may not be invoked. As a result, breadcrumbs are not recorded.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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
OK. That, at the very least, puts a cap on the number of breadcrumbs that can pile up. You’ll only ever have a maximum of 100 per scope (by default). So memory consumption on the application won’t grow indefinitely.
You still have a practical problem of ensuring that you have all the relevant breadcrumbs and they’re not drowned out in the noise of a bunch of irrelevant logs.
There are a couple of tools at your disposal there.
You can set minimum levels when configuring logging:
Another is the
SetBeforeBreadcrumb
hook but you need some way to sift the logs/breadcrumbs you’re interested in from those you’re not. I’m not sure I have any silver bullets there… it might be a matter of playing around to see if there are any obvious markers in combinations of things likeBreadcrumb.Type
,Breadcrumb.Category
or possibly information stored in theBreadcrumb.Data
dictionary.