Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Instrument ¶
Instrument instruments the mux.Router so that requests are traced.
Instrument installs middleware into r, and alsos overrides r.NotFoundHandler and r.MethodNotAllowedHandler so that they are traced. If you modify either of those fields, you must do so before calling Instrument.
func Middleware ¶
func Middleware(o ...Option) mux.MiddlewareFunc
Middleware returns a new gorilla/mux middleware handler for tracing requests and reporting errors.
This middleware will recover and report panics, so it can be used instead of the gorilla/middleware.RecoveryHandler middleware.
Middleware does not get invoked when a route cannot be matched, or when an unsupported method is used. To report transactions in these cases, you should use the Instrument function, or set the router's NotFoundHandler and MethodNotAllowedHandler fields using the Wrap functions in this package.
By default, the middleware will use apm.DefaultTracer(). Use WithTracer to specify an alternative tracer.
func WrapMethodNotAllowedHandler ¶
WrapMethodNotAllowedHandler wraps h with m. If h is nil, then a default handler will be used that returns status code 405.
func WrapNotFoundHandler ¶
WrapNotFoundHandler wraps h with m. If h is nil, then http.NotFoundHandler() will be used.
Types ¶
type Option ¶
type Option func(*options)
Option sets options for tracing.
func WithPanicPropagation ¶
func WithPanicPropagation() Option
WithPanicPropagation returns a Option which enable panic propagation. Any panic will be recovered and recorded as an error in a transaction, then panic will be caused again.
func WithRequestIgnorer ¶
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 *apm.Tracer) Option
WithTracer returns an Option which sets t as the tracer to use for tracing server requests.