Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Golang "github.com/newrelic/go-agent/_integrations/nrgorilla/v1" -- nrgorilla.InstrumentRoutes

go-agent

#1

Please add string or spring… args params to filter out certain routes names.

We have Hearthbeat., health check routes that we do not want to be tracked in new relic…

We had to get nrgorilla.go and modify the instrument function in order to achive this… A product support would be nice…
func InstrumentRoutes(r *mux.Router, app newrelic.Application, heartbeat string) *mux.Router {
r.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
if route.GetName() == heartbeat {
return nil
}
h := instrumentRoute(route.GetHandler(), app, routeName(route))
route.Handler(h)
return nil
})
if nil != r.NotFoundHandler {
r.NotFoundHandler = instrumentRoute(r.NotFoundHandler, app, “NotFoundHandler”)
}
return r

}


Go integrations/nrgorilla -- exclued heart beat routes.. can the exclude route names be added?
#2
Duplicate post

func InstrumentRoutes(r *mux.Router, app newrelic.Application, heartbeat string) *mux.Router {
r.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
if route.GetName() == heartbeat {
return nil
}
fmt.Println("instrumenting " + route.GetName())
h := instrumentRoute(route.GetHandler(), app, routeName(route))
route.Handler(h)
return nil
})
if nil != r.NotFoundHandler {
r.NotFoundHandler = instrumentRoute(r.NotFoundHandler, app, “NotFoundHandler”)
}
return r

}


#3

Here is the better version of this method:
/ InstrumentRoutes adds instrumentation to a router. This must be used after
// the routes have been added to the router.
func InstrumentRoutesFiltered(r *mux.Router, app newrelic.Application, excludeRouteNames …string) *mux.Router {
r.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
for _, routeName := range excludeRouteNames {
if route.GetName() == routeName {
return nil
}
}

    h := instrumentRoute(route.GetHandler(), app, routeName(route))
    route.Handler(h)
    return nil
})
if nil != r.NotFoundHandler {
    r.NotFoundHandler = instrumentRoute(r.NotFoundHandler, app, "NotFoundHandler")
}
return r

}

And call out looks like:

nrgorilla. InstrumentRoutesFiltered(router, app, “heartbeat”,"info”)

Thanks


#4

Hi Alexander

I recommend using the Transaction.Ignore method in the handlers that you do not want instrumented. You can access the transaction by calling newrelic.FromContext on the request context.

Would this strategy work for you? We are eager to keep the public interface as small as possible.