-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration package for go-chi #450
Comments
Has anyone implemented an new rekic v3 middleware for go-chi yet? |
Using the func ServeHTTP(w http.ResponseWriter, r *http.Request) {
routePattern := "NotFoundHandler"
rctx := chi.NewRouteContext()
if mux.Match(rctx, r.Method, r.URL.Path) {
routePattern = rctx.RoutePattern()
}
txn := nrapp.StartTransaction(r.Method + " " + routePattern)
defer txn.End()
w = txn.SetWebResponse(w)
txn.SetWebRequestHTTP(r)
r = newrelic.RequestWithTransactionContext(r, txn)
mux.ServeHTTP(w, r)
} |
Here is a nice working example of a |
Hi, is this PR or issue still pending review? Can I give some advice on the implementation? Maybe it's better to use it as a public function for example: func Middleware(app *newrelic.Application) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
txn := app.StartTransaction(r.Method + r.URL.RequestURI())
defer txn.End()
txn.SetWebRequestHTTP(r)
w = txn.SetWebResponse(w)
r = newrelic.RequestWithTransactionContext(r, txn)
next.ServeHTTP(w, r)
}
return http.HandlerFunc(fn)
}
} And then when we use package main
...
func main() {
app, err := newrelic.NewApplication(
newrelic.ConfigAppName("go-chi App"),
newrelic.ConfigLicense(os.Getenv("NEW_RELIC_LICENSE_KEY")),
newrelic.ConfigDebugLogger(os.Stdout),
)
if nil != err {
fmt.Println(err)
os.Exit(1)
}
r := chi.NewRouter(app)
r.Use(nrchi.Middleware(app))
r.Use(middleware.RequestID)
r.Use(middleware.Logger)
r.Use(middleware.Recoverer)
...
} |
Hi, go-chi has been very popular among the go developers, specially for it's light weight implementation. It would be great if we could receive some update on this from New Relic team. |
Hello all, An integration package for go-chi is currently on our roadmap. While we don't have an exact ETA just yet, we know this is a highly requested integration so we'll post any updates in this thread. |
Hello all, I'm happy to report that Go-Chi support is in active development! |
Add an integration package for the go-chi router
Summary
This page recommends opening a ticket to request new integration packages. This issue was opened in the past but was closed last April without comment, so I'm opening a new issue requesting the addition of this package.
The text was updated successfully, but these errors were encountered: