apmgorilla

package module
v1.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2021 License: Apache-2.0 Imports: 6 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Instrument added in v1.4.0

func Instrument(r *mux.Router, o ...Option)

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 added in v1.4.0

func WrapMethodNotAllowedHandler(h http.Handler, m mux.MiddlewareFunc) http.Handler

WrapMethodNotAllowedHandler wraps h with m. If h is nil, then a default handler will be used that returns status code 405.

func WrapNotFoundHandler added in v1.4.0

func WrapNotFoundHandler(h http.Handler, m mux.MiddlewareFunc) http.Handler

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 added in v1.12.0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL