apm-agent-go: github.com/elastic/apm-agent-go/module/apmgorilla Index | Files

package apmgorilla

import "github.com/elastic/apm-agent-go/module/apmgorilla"


Package Files

context.go middleware.go

func Instrument Uses

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 Uses

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 Uses

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 Uses

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.

type Option Uses

type Option func(*options)

Option sets options for tracing.

func WithRequestIgnorer Uses

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 Uses

func WithTracer(t *apm.Tracer) Option

WithTracer returns an Option which sets t as the tracer to use for tracing server requests.

Package apmgorilla imports 6 packages (graph). Updated 2020-05-06. Refresh now. Tools for package owners.