-
-
Notifications
You must be signed in to change notification settings - Fork 226
feat: Added SessionEndStatus.Unhandled
#4633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: version6
Are you sure you want to change the base?
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## version6 #4633 +/- ##
===========================================
Coverage ? 73.21%
===========================================
Files ? 480
Lines ? 17417
Branches ? 3437
===========================================
Hits ? 12751
Misses ? 3812
Partials ? 854 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This is really annoying.. running
because
and all I want to do is to please Verify... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while talking through this a bigger problem has been uncovered, with restarting sessions on unhandled
if (exception.Data[Mechanism.TerminalKey] is bool terminal) | ||
{ | ||
mechanism.Terminal = terminal; | ||
exception.Data.Remove(Mechanism.TerminalKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to remove? curious why
var source = json.GetPropertyOrNull("source")?.GetString(); | ||
var helpLink = json.GetPropertyOrNull("help_link")?.GetString(); | ||
var handled = json.GetPropertyOrNull("handled")?.GetBoolean(); | ||
var terminal = json.GetPropertyOrNull("terminal")?.GetBoolean(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like wer'e changing the wire protocol here. Do we need this? afaik the Exception interface has some Data
bag we could use instead.
In any case we need to check this is even accepted by Relay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only spotted the changes to the SessionUpdate
protocol:
Are there also changes to the Mechanism protocol?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All server changes so far are about sessions. Nothing related to events
test/Sentry.AspNetCore.TestUtils/Sentry.AspNetCore.TestUtils.csproj
Outdated
Show resolved
Hide resolved
var source = json.GetPropertyOrNull("source")?.GetString(); | ||
var helpLink = json.GetPropertyOrNull("help_link")?.GetString(); | ||
var handled = json.GetPropertyOrNull("handled")?.GetBoolean(); | ||
var terminal = json.GetPropertyOrNull("terminal")?.GetBoolean(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only spotted the changes to the SessionUpdate
protocol:
Are there also changes to the Mechanism protocol?
return SentryExceptions?.Any(e => e.Mechanism is { Handled: false }) ?? false; | ||
} | ||
|
||
internal bool HasUnhandledNonTerminalException() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: order
Do I get that right that, for correct consumption, we need to call these methods in this order
HasUnhandledNonTerminalException
HasUnhandledException
HasException
Then there is also HasTerminalException
.
It's a bit confusing to me ... I wonder if this could be designed a bit more clearly.
On the other hand ... this may just be me ... and the methods are all internal
.
/// <summary> | ||
/// Session ended with an unhandled exception. | ||
/// </summary> | ||
Unhandled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: breaking change
We ship this in a major release, so this may be a non-concern.
But inserting an enum
member is a breaking change for users that have code like:
_ = (SessionEndStatus)1;
Well ... I guess it's unlikely that a considerable amount of user code does this ... I just wanted to hear your thoughts.
Problem
The SDK should use the new
SessionEndStatus.Unhandled
when capturing an unhandled exception that does not cause the application to crash.Unhandled exceptions typically lead to a terminal state of the application. The only exception (hehe) to this was the
UnobservedTaskExceptionIntegration
. Another instance where this is highly relevant is Unity: Unhandled exceptions get "swallowed" by the engine and the game just continues.Context
Within the Sentry SDK for .NET the only non-terminal unhandled exception comes from the
UnobservedTaskExceptionIntegration
that also gets special cased inSentryEvent.HasTerminalException()
where we compare against the mechanism keysentry-dotnet/src/Sentry/SentryEvent.cs
Lines 188 to 191 in 04c932b
This is limiting as it does not allow for other integrations i.e. coming from the Unity SDK to add to this check.
Proposal
Option 1: Add list ofNonTerminalMechanismKey
on the optionsOne straight forward solution to this would be to have an
internal List<string>? NonTerminalMechanismKeys;
onthe options and have integrations add to the list during their registration. We'd need to pass the options into the
HasTerminalException
check but they are available everywhere we'd need them.There are a couple of downsides to this:
internal
orpublic
. If we keep itinternal
the Unity SDK can add to it but no user written integration can.Option 2: Rework the Mechanismbool? Handled
to an explicitenum ExceptionHandledState
The
Terminal
state is only ever relevant in case of anUnhandled Exception
. This makes the additional property somewhat redundant. An alternative solution would be to replace thebool? Handled
with an explicitExceptionHandledState
. This would be quite the breaking change and we'd need to take special care during serialization.Option 3: Extend
Mechanism
to have abool? Terminal
propertyThe mechanism on the exception already has things like
Handled
andSynthetic
. We could extend this by addingbool? Terminal
. Integrations that capture unhandled non-terminal exceptions can set theTerminal
state tofalse
and we can check for this on theSentryEvent
.This sounds to me the most pragmatic and minimal invasive change. The only downside I can see right now is that the property is only ever going to be useful when
Handled
isfalse
. But we can keep it nullable.