extended code level metrics options to the WrapHandle and WrapHandleFunc functions.
@@ -28,12 +28,16 @@ import (
// }
//
// The WrapHandle function is safe to call if app is nil.
-func WrapHandle(app *Application, pattern string, handler http.Handler) (string, http.Handler) {
+//
+// WrapHandle accepts zero or more TraceOption functions to allow additional options to be
+// manually added to the transaction trace generated, in the same fashion as StartTransaction
+// does. For example, this can be used to control code level metrics generated for this transaction.
+func WrapHandle(app *Application, pattern string, handler http.Handler, options ...TraceOption) (string, http.Handler) {
if app == nil {
return pattern, handler
}
return pattern, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- txn := app.StartTransaction(r.Method + " " + pattern)
+ txn := app.StartTransaction(r.Method+" "+pattern, options...)
defer txn.End()
w = txn.SetWebResponse(w)
@@ -68,8 +72,12 @@ func WrapHandle(app *Application, pattern string, handler http.Handler) (string,
// }))
//
// The WrapHandleFunc function is safe to call if app is nil.
-func WrapHandleFunc(app *Application, pattern string, handler func(http.ResponseWriter, *http.Request)) (string, func(http.ResponseWriter, *http.Request)) {
- p, h := WrapHandle(app, pattern, http.HandlerFunc(handler))
+//
+// WrapHandleFunc accepts zero or more TraceOption functions to allow additional options to be
+// manually added to the transaction trace generated, in the same fashion as StartTransaction
+// does. For example, this can be used to control code level metrics generated for this transaction.
+func WrapHandleFunc(app *Application, pattern string, handler func(http.ResponseWriter, *http.Request), options ...TraceOption) (string, func(http.ResponseWriter, *http.Request)) {
+ p, h := WrapHandle(app, pattern, http.HandlerFunc(handler), options...)
return p, func(w http.ResponseWriter, r *http.Request) { h.ServeHTTP(w, r) }
}
