mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-05-14 03:01:48 +00:00
Report update errors or timeouts.
Looking through Sentry history, `update <domain> err:` is an extremely high SNR signal of something going wrong; from configuration errors on our side, to people pushing too-large git repositories and it failing. Either way we should know.
This commit is contained in:
@@ -130,6 +130,12 @@ func FiniObservability() {
|
||||
}
|
||||
}
|
||||
|
||||
func ObserveError(err error) {
|
||||
if hasSentry() {
|
||||
go sentry.CaptureException(err)
|
||||
}
|
||||
}
|
||||
|
||||
type observedResponseWriter struct {
|
||||
inner http.ResponseWriter
|
||||
status int
|
||||
|
||||
@@ -328,6 +328,7 @@ func putPage(w http.ResponseWriter, r *http.Request) error {
|
||||
|
||||
switch result.outcome {
|
||||
case UpdateError:
|
||||
ObserveError(result.err)
|
||||
if errors.Is(result.err, ErrManifestTooLarge) {
|
||||
w.WriteHeader(http.StatusRequestEntityTooLarge)
|
||||
} else if errors.Is(result.err, errArchiveFormat) {
|
||||
@@ -338,6 +339,7 @@ func putPage(w http.ResponseWriter, r *http.Request) error {
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
}
|
||||
case UpdateTimeout:
|
||||
ObserveError(fmt.Errorf("update timeout"))
|
||||
w.WriteHeader(http.StatusGatewayTimeout)
|
||||
case UpdateNoChange:
|
||||
w.Header().Add("X-Pages-Update", "no-change")
|
||||
@@ -511,9 +513,11 @@ func postPage(w http.ResponseWriter, r *http.Request) error {
|
||||
|
||||
switch result.outcome {
|
||||
case UpdateError:
|
||||
ObserveError(result.err)
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
fmt.Fprintf(w, "update error: %s\n", result.err)
|
||||
case UpdateTimeout:
|
||||
ObserveError(fmt.Errorf("update timeout"))
|
||||
w.WriteHeader(http.StatusGatewayTimeout)
|
||||
fmt.Fprintln(w, "update timeout")
|
||||
case UpdateNoChange:
|
||||
|
||||
Reference in New Issue
Block a user