Skip to content

Commit

Permalink
logcrash: add ReportTypeAssertionFailure
Browse files Browse the repository at this point in the history
Epic: none
Release note: None
  • Loading branch information
erikgrinaker committed Jul 28, 2023
1 parent 5f384b3 commit 4ffc54c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/util/log/logcrash/crash_reporting.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ const (
// ReportTypeLogFatal signifies that this is an error report that
// was generated via a log.Fatal call.
ReportTypeLogFatal
// ReportTypeAssertionFailure signifies that an assertion was violated (see
// expect package).
ReportTypeAssertionFailure
)

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

for _, f := range tagFns {
Expand Down Expand Up @@ -437,13 +442,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 4ffc54c

Please sign in to comment.