소스 검색

Recover on HTTP handler panics, and send Error status event for message based panics.

Matt Bolt 6 년 전
부모
커밋
ae50f6aeb2
1개의 변경된 파일7개의 추가작업 그리고 4개의 파일을 삭제
  1. 7 4
      pkg/costmodel/router.go

+ 7 - 4
pkg/costmodel/router.go

@@ -891,14 +891,17 @@ func handlePanic(p errors.Panic) bool {
 
 		if err, ok := err.(string); ok {
 			msg := fmt.Sprintf("Panic: %s\nStackTrace: %s\n", err, p.Stack)
-			sentry.CurrentHub().CaptureMessage(msg)
+			sentry.CurrentHub().CaptureEvent(&sentry.Event{
+				Level:   sentry.LevelError,
+				Message: msg,
+			})
 			sentry.Flush(5 * time.Second)
 		}
 	}
 
-	// Return false to not recover
-	// We'll allow kubernetes to handle crash/failures
-	return false
+	// Return true to recover iff the type is http, otherwise allow kubernetes
+	// to recover.
+	return p.Type == errors.PanicTypeHTTP
 }
 
 func Initialize(additionalConfigWatchers ...ConfigWatchers) {