go-json-rest icon indicating copy to clipboard operation
go-json-rest copied to clipboard

[Question] Gorelic WrapHTTPHandler integration

Open gregorypease280 opened this issue 8 years ago • 2 comments

Related to #192

I'm trying to use gorelic's agent.WrapHTTPHandler to monitor individual endpoints however I'm running into issues translating between the http.HandlerFunc and rest.HandlerFunc. I assume it should be possible/fairly easy however I'm still new to golang and not entirely familiar with interfaces and the like.... I would greatly appreciate an example of how to achieve this and I'll put in PR for the readme once I figure it out. Thanks!

gregorypease280 avatar Nov 05 '16 01:11 gregorypease280

Hi,

The return value of api.MakeHandler() is a net/http Handler. Have you tried to give that value to gorelic's agent.WrapHTTPHandler ?

ant0ine avatar Nov 05 '16 01:11 ant0ine

Hi ant0ine,

Currently I'm doing exactly that

`router, err := rest.MakeRouter(
        rest.Get("/hb", hb),
        rest.Get("/section/item", thing.GetThings),
        rest.Get("/section/item/:id", thing.GetThing),
    )
    if err != nil {
        log.Fatal(err)
    }
    api.SetApp(router)
    http.ListenAndServe(port, agent.WrapHTTPHandler(api.MakeHandler()))`

Perhaps the problem is on gorelic's side of things but what I would like to do is wrap thing.GetThings, thing.GetThing etc... individually in order to monitor which endpoints are failing etc... through newrelic's APM(which now I'm doubting whether or not gorelic is capable of). I see data come in through the NewRelic plugin page but nothing on APM.

gregorypease280 avatar Nov 07 '16 18:11 gregorypease280