You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is this just about the breadcrumbs list having entries from before that scope? Or any other data from the scope isn't relevant?
Because this could be a matter of PushScope having some argument to return an empty scope. Or Scope could have a Clear method. Or just the Breadcrumbs on the scope could have a clear method
Is this just about the breadcrumbs list having entries from before that scope?
Yes
Another example could be the following:
Some Framework code we have no control over
while(true)
{
var message = FetchNextMessage();
_logger.LogInformation("Fetched message with id {id}", message.id);
ProcessMessage(message);
_logger.LogInformation("Processed message with id {id}", message.id);
}
Where you can implement a 'Processor'
public class MyProcessor : IProcessor
{
public Task Process(Message message)
{
using var scope = _hub.PushScope();
_logger.LogInformation("...");
//Throw an exception here
//Or send an event to sentry
}
}
The breadcrumbs slowly get filled with the framework code from previous messages (which we can't control)
This can quickly lead to thousand / millions of (unrelated) breadcrumbs being sent with events (a leak if you like)
So having something like a _hub.StartScope(); or _hub.NewScope(); or scope.Clear() would be very handy in this use case
Activity
bruno-garcia commentedon Jun 14, 2022
Is this just about the breadcrumbs list having entries from before that scope? Or any other data from the scope isn't relevant?
Because this could be a matter of PushScope having some argument to return an empty scope. Or Scope could have a Clear method. Or just the Breadcrumbs on the scope could have a clear method
Vandersteen commentedon Jun 14, 2022
Yes
Another example could be the following:
Some Framework code we have no control over
Where you can implement a 'Processor'
The breadcrumbs slowly get filled with the framework code from previous messages (which we can't control)
This can quickly lead to thousand / millions of (unrelated) breadcrumbs being sent with events (a leak if you like)
So having something like a _hub.StartScope(); or _hub.NewScope(); or scope.Clear() would be very handy in this use case
bruno-garcia commentedon Jun 15, 2022
Clear scope is a fair API and IIRC we expose in some SDKs.
Java has for crumbs: https://github.com/getsentry/sentry-java/blob/a88509c1b7b51bad58053b2457a79dd22fe29f70/sentry/src/main/java/io/sentry/Scope.java#L358-L360
And one to clear everything: https://github.com/getsentry/sentry-java/blob/a88509c1b7b51bad58053b2457a79dd22fe29f70/sentry/src/main/java/io/sentry/Scope.java#L381-L392
bruno-garcia commentedon Jun 15, 2022
@Vandersteen would you be willing to send a PR to add Clear?
Vandersteen commentedon Aug 30, 2022
@bruno-garcia I might be able to free some time, no promises thought.
Could you point me in the right direction ?
mattjohnsonpint commentedon Dec 12, 2022
FWIW, it appears that
scope.Clearandscope.ClearBreadcrumbsare defined in the Unified API spec, so we should definitely add them.https://develop.sentry.dev/sdk/unified-api/#scope
hheexx commentedon Dec 28, 2022
Also please add SentryEvent.ClearBreadcrumbs() so we can clear breadcrumbs in BeforeSend.
(i'm not sure if this is seperate or same)
mattjohnsonpint commentedon Mar 30, 2023
Hi. Just for clarity, I've created two new issue to track this work:
Scope.ClearandScope.ClearBreadcrumbs#2272SentryEventpublic API #2273Closing this issue in favor of those. Thanks.
mattjohnsonpint commentedon Apr 14, 2023
Scope.Clearhas been released in 3.30.0.See example: in #2274
Also, just to clarify
options.IsGlobalModeshould befalse(which is the default).