Skip to content

Commit

Permalink
rely on sentry for error tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Aug 18, 2017
1 parent 4aa6867 commit fd8c816
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package courier
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/http/httputil"
Expand Down Expand Up @@ -63,7 +61,6 @@ func NewServerWithLogger(config *config.Courier, backend Backend, logger *logrus
router.Use(middleware.DefaultCompress)
router.Use(middleware.RequestID)
router.Use(middleware.RealIP)
router.Use(traceErrors(logger))
router.Use(lg.RequestLogger(logger))
router.Use(middleware.Recoverer)
router.Use(middleware.Timeout(15 * time.Second))
Expand Down Expand Up @@ -377,26 +374,6 @@ func (s *server) handleIndex(w http.ResponseWriter, r *http.Request) {
w.Write(buf.Bytes())
}

func traceErrors(logger *logrus.Logger) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
body := bytes.Buffer{}
r.Body = ioutil.NopCloser(io.TeeReader(r.Body, &body))
ww := middleware.NewWrapResponseWriter(w, r.ProtoMajor)
next.ServeHTTP(ww, r)

// we are returning an error of some kind, log the incoming request body
if ww.Status() != 200 && strings.ToLower(r.Method) == "post" {
logger.WithFields(logrus.Fields{
"request_body": body.String(),
"status": ww.Status(),
"req_id": r.Context().Value(middleware.RequestIDKey)}).Error()
}
}
return http.HandlerFunc(fn)
}
}

var splash = `
____________ _____
___ ____/_________ ___________(_)____________
Expand Down

0 comments on commit fd8c816

Please sign in to comment.