getsentry / raven-go

Sentry client in Go
https://sentry.io
BSD 3-Clause "New" or "Revised" License
561 stars 148 forks source link

Errors registering with wrong request URL (GorillaMux, CaptureError, Recovery Handler) #244

Open nchudleigh opened 5 years ago

nchudleigh commented 5 years ago

Using gorilla/mux v1.6.1

I am noticing errors come through to Sentry that have the wrong Request URL for the Handler that gets called.

The specific situation I am seeing in Sentry is Handler3 being called for a request to /two/user_1234.

The other strange thing is Handler2 is called hundreds of times per minute. But the error is raised infrequently (a couple hundred times in the past 5 days)

I have tried to replicate this locally but as I cannot mimic the functionality.

Given the implementation below is it possible that a error raised from a request is being tagged with the wrong Request URL?

If this is not the case I will move on to the gorilla/mux issues.

// Router creates router for the server
func Router() *mux.Router {
    r := mux.NewRouter()

    r.HandleFunc("/one", raven.RecoveryHandler(Handler1)).Methods("GET")
    r.HandleFunc("/two/{key}", raven.RecoveryHandler(Handler2)).Methods("GET")
    r.HandleFunc("/{id}", raven.RecoveryHandler(Handler3)).Methods("GET")

    return r
}

func main() {
    r := Router()

    srv := &http.Server{
        Handler:      r,
        Addr:         ":" + PORT,
        ReadTimeout:  2 * time.Second,
        WriteTimeout: 2 * time.Second,
    }

    log.Printf("Listening on http://127.0.0.1:%s\n", PORT)
    err := srv.ListenAndServe()
    if err != nil {
        log.Fatalf("ListenAndServe(): %s", err)
        raven.CaptureError(err, nil)
    }
}