Skip to content

v3.2.0

Compare
Choose a tag to compare
@willnewrelic willnewrelic released this 27 Jan 19:10
· 1372 commits to master since this release

New Features

Changes

  • Updated Gorilla instrumentation to include request time spent in middlewares. Added new nrgorilla.Middleware and deprecated nrgorilla.InstrumentRoutes. Register the new middleware as your first middleware using Router.Use. See the godocs examples for more details.

    r := mux.NewRouter()
    // Always register the nrgorilla.Middleware first.
    r.Use(nrgorilla.Middleware(app))
    
    // All handlers and custom middlewares will be instrumented.  The
    // transaction will be available in the Request's context.
    r.Use(MyCustomMiddleware)
    r.Handle("/", makeHandler("index"))
    
    // The NotFoundHandler and MethodNotAllowedHandler must be instrumented
    // separately using newrelic.WrapHandle.  The second argument to
    // newrelic.WrapHandle is used as the transaction name; the string returned
    // from newrelic.WrapHandle should be ignored.
    _, r.NotFoundHandler = newrelic.WrapHandle(app, "NotFoundHandler", makeHandler("not found"))
    _, r.MethodNotAllowedHandler = newrelic.WrapHandle(app, "MethodNotAllowedHandler", makeHandler("method not allowed"))
    
    http.ListenAndServe(":8000", r)