Documentation ¶
Index ¶
- func Wrap(h httprouter.Handle, route string, o ...Option) httprouter.Handle
- type Option
- type Router
- func (r *Router) DELETE(path string, handle httprouter.Handle)
- func (r *Router) GET(path string, handle httprouter.Handle)
- func (r *Router) HEAD(path string, handle httprouter.Handle)
- func (r *Router) Handle(method, path string, handle httprouter.Handle)
- func (r *Router) Handler(method, path string, handler http.Handler)
- func (r *Router) HandlerFunc(method, path string, handler http.HandlerFunc)
- func (r *Router) OPTIONS(path string, handle httprouter.Handle)
- func (r *Router) PATCH(path string, handle httprouter.Handle)
- func (r *Router) POST(path string, handle httprouter.Handle)
- func (r *Router) PUT(path string, handle httprouter.Handle)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Wrap ¶
func Wrap(h httprouter.Handle, route string, o ...Option) httprouter.Handle
Wrap wraps h such that it will report requests as transactions to Elastic APM, using route in the transaction name.
By default, the returned Handle will use elasticapm.DefaultTracer. Use WithTracer to specify an alternative tracer.
By default, the returned Handle will recover panics, reporting them to the configured tracer. To override this behaviour, use WithRecovery.
Types ¶
type Option ¶
type Option func(*options)
Option sets options for tracing.
func WithRecovery ¶
func WithRecovery(r apmhttp.RecoveryFunc) Option
WithRecovery returns an Option which sets r as the recovery function to use for tracing server requests.
func WithRequestIgnorer ¶ added in v0.5.0
func WithRequestIgnorer(r apmhttp.RequestIgnorerFunc) Option
WithRequestIgnorer returns a Option which sets r as the function to use to determine whether or not a request should be ignored. If r is nil, all requests will be reported.
func WithTracer ¶
func WithTracer(t *elasticapm.Tracer) Option
WithTracer returns an Option which sets t as the tracer to use for tracing server requests.
type Router ¶ added in v0.5.0
type Router struct { *httprouter.Router // contains filtered or unexported fields }
Router wraps an httprouter.Router, instrumenting all added routes except static content served with ServeFiles.
func New ¶ added in v0.5.0
New returns a new Router which will instrument all added routes except static content served with ServeFiles.
func (*Router) DELETE ¶ added in v0.5.0
func (r *Router) DELETE(path string, handle httprouter.Handle)
DELETE calls r.Router.DELETE with a wrapped handler.
func (*Router) GET ¶ added in v0.5.0
func (r *Router) GET(path string, handle httprouter.Handle)
GET calls r.Router.GET with a wrapped handler.
func (*Router) HEAD ¶ added in v0.5.0
func (r *Router) HEAD(path string, handle httprouter.Handle)
HEAD calls r.Router.HEAD with a wrapped handler.
func (*Router) Handle ¶ added in v0.5.0
func (r *Router) Handle(method, path string, handle httprouter.Handle)
Handle calls r.Router.Handle with a wrapped handler.
func (*Router) Handler ¶ added in v0.5.0
Handler is equivalent to r.Router.Handler, but traces requests.
func (*Router) HandlerFunc ¶ added in v0.5.0
func (r *Router) HandlerFunc(method, path string, handler http.HandlerFunc)
HandlerFunc is equivalent to r.Router.HandlerFunc, but traces requests.
func (*Router) OPTIONS ¶ added in v0.5.0
func (r *Router) OPTIONS(path string, handle httprouter.Handle)
OPTIONS is equivalent to r.Router.OPTIONS, but traces requests.
func (*Router) PATCH ¶ added in v0.5.0
func (r *Router) PATCH(path string, handle httprouter.Handle)
PATCH is equivalent to r.Router.PATCH, but traces requests.