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

Looking for help with golang agent, go-chi, and newrelic instrumentation




I have a Go app (built around instrumented with newrelic using a chi-middleware snippet). Basic reporting work, but newrelic doesn’t seem to record HTTP errors. Generally the support looks bad enough that I think I might not have instrumented it correctly.

Is there a Slack group/channel? Are you guys in the golang slack ?

Instrumented code looks somewhat like

func instrumentNewRelic(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
	txn := newRelicApp.StartTransaction(
		generalizeURL(r.URL.Path), w, r)
	next.ServeHTTP(w, r)
return http.HandlerFunc(fn)

// generalizeURL removes dynamic params

// elsewhere

r := chi.NewRouter()
    // ....
    // ....

Any help is appreciated.




Hey @harikb that does look good to generally instrument the http calls for transaction response times. One thing I do not see is any reference to NoticeError. We have an example of how to instrument/report errors here in our Go Agent Guide.


Hi Harry

You need to use the Transaction in place of the ResponseWriter when calling next.ServeHTTP. The Transaction wraps the ResponseWriter and records the HTTP status code! You want: