Skip to content

Commit

Permalink
logcrash: add ReportTypeAssertionFailed
Browse files Browse the repository at this point in the history
Epic: none
Release note: None
  • Loading branch information
erikgrinaker committed Oct 7, 2023
1 parent 981b050 commit 5251b37
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/util/log/logcrash/crash_reporting.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ const (
// ReportTypeLogFatal signifies that this is an error report that
// was generated via a log.Fatal call.
ReportTypeLogFatal
// ReportTypeAssertionFailed signifies that a runtime assertion was violated.
ReportTypeAssertionFailed
)

// sendCrashReport posts to sentry.
Expand Down Expand Up @@ -384,6 +386,8 @@ func SendReport(
event.Tags["report_type"] = "error"
case ReportTypeLogFatal:
event.Tags["report_type"] = "log_fatal"
case ReportTypeAssertionFailed:
event.Tags["report_type"] = "assertion"
}

for _, f := range tagFns {
Expand Down Expand Up @@ -445,13 +449,15 @@ func RegisterTagFn(key string, value func(context.Context) string) {
tagFns = append(tagFns, tagFn{key, value})
}

func maybeSendCrashReport(ctx context.Context, err error) {
func maybeSendCrashReport(ctx context.Context, err error, reportType ReportType) {
// We load the ReportingSettings from global singleton in this call path.
if sv := getGlobalSettings(); sv != nil {
sendCrashReport(ctx, sv, err, ReportTypeLogFatal)
sendCrashReport(ctx, sv, err, reportType)
}
}

func init() {
log.MaybeSendCrashReport = maybeSendCrashReport
log.MaybeSendCrashReport = func(ctx context.Context, err error) {
maybeSendCrashReport(ctx, err, ReportTypeLogFatal)
}
}

0 comments on commit 5251b37

Please sign in to comment.