-
-
Notifications
You must be signed in to change notification settings - Fork 207
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
All exceptions are now added as breadcrumbs on future events #3584
Conversation
…r from logging integrations)
var exceptionMessage = exception.Message ?? ""; | ||
var formatted = evt.Message?.Formatted; | ||
|
||
string breadcrumbMessage; | ||
Dictionary<string, string>? data = null; | ||
if (string.IsNullOrWhiteSpace(formatted)) | ||
{ | ||
breadcrumbMessage = exceptionMessage; | ||
} | ||
else | ||
{ | ||
breadcrumbMessage = formatted; | ||
// Exception.Message won't be used as Breadcrumb message | ||
// Avoid losing it by adding as data: | ||
data = new Dictionary<string, string> | ||
{ | ||
{"exception_message", exceptionMessage} | ||
}; | ||
} |
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.
Just double-checking: If I've got my log-level set to Warning
and the SDK creates an event out of a log warning:
- The minimum level is reached and the integration captures an event, skipping the breadcrumb creation
- From the logging integration we get here
- There was no exception - we bail early
- Warnings don't get added as breadcrumbs by neither the logging integration nor the core SDK?
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.
Nice catch... have pushed a new commit to fix (the SentryLogger
and SentrySink
now do create breadcrumbs for events, if no exceptions are associated with those events).
I think that's the correct behaviour since CaptureEvent
is also used by CaptureMessage
(and I assume we don't want to automatically add breadcrumbs for calls to CaptureMessage
):
sentry-dotnet/src/Sentry/HubExtensions.cs
Line 221 in f22c2d4
return hub.CaptureEvent(sentryEvent, configureScope); |
I noticed this in the NLog options: sentry-dotnet/src/Sentry.NLog/SentryNLogOptions.cs Lines 47 to 51 in 57feab3
Initially I thought that was related to this ticket but actually it's just confusion over the use of the word "Event" which, in this context, means the logging event (not a sentry event). This settings determines whether "Logging Event" data gets added as context for breadcrumbs: sentry-dotnet/src/Sentry.NLog/SentryTarget.cs Lines 418 to 432 in 2ef9f80
So, back to the original plan. |
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.
Nice!
Resolves #3444
This is a bit redundant if tracing is enabled. In that case there is a notification at the top of the event informing you of any other exceptions(s) that have been encountered within the same trace: