I was trying to capture the system resources used by http handler, Latency etc. Since there is no newrelic agent for go lang. So, I found this goRelic agent.
Which says using the folowing way i can capture the http metric:
agent.CollectHTTPStat = true
http.HandleFunc("/", agent.WrapHTTPHandlerFunc(handler))
But the problem is i am using custom http handler given in the link as follows:
type appHandler struct {
*appContext
H func(*appContext, http.ResponseWriter, *http.Request) (int, error)
}
func (ah appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Updated to pass ah.appContext as a parameter to our handler type.
status, err := ah.H(ah.appContext, w, r)
if err != nil {
log.Printf("HTTP %d: %q", status, err)
switch status {
case http.StatusNotFound:
http.NotFound(w, r)
// And if we wanted a friendlier error page, we can
// now leverage our context instance - e.g.
// err := ah.renderTemplate(w, "http_404.tmpl", nil)
case http.StatusInternalServerError:
http.Error(w, http.StatusText(status), status)
default:
http.Error(w, http.StatusText(status), status)
}
}
}
func main() {
r := web.New()
// We pass an instance to our context pointer, and our handler.
r.Get("/", appHandler{context, IndexHandler})
graceful.ListenAndServe(":8086", r)
}
So, how do i capture the http metric for this handle or is there any other tool by which i can capture the similar metrics?