apmhttprouter

package module
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

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 apm.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.

func WrapMethodNotAllowedHandler

func WrapMethodNotAllowedHandler(h http.Handler, o ...Option) http.Handler

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

func WrapNotFoundHandler

func WrapNotFoundHandler(h http.Handler, o ...Option) http.Handler

WrapNotFoundHandler wraps h so that it is traced. If h is nil, then http.NotFoundHandler() will be used.

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

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.

type Router

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

func New(o ...Option) *Router

New returns a new Router which will instrument all added routes except static content served with ServeFiles.

Router.NotFound and Router.MethodNotAllowed will be set, and will report transactions with the name "<METHOD> unknown route".

func (*Router) DELETE

func (r *Router) DELETE(path string, handle httprouter.Handle)

DELETE calls r.Router.DELETE with a wrapped handler.

func (*Router) GET

func (r *Router) GET(path string, handle httprouter.Handle)

GET calls r.Router.GET with a wrapped handler.

func (*Router) HEAD

func (r *Router) HEAD(path string, handle httprouter.Handle)

HEAD calls r.Router.HEAD with a wrapped handler.

func (*Router) Handle

func (r *Router) Handle(method, path string, handle httprouter.Handle)

Handle calls r.Router.Handle with a wrapped handler.

func (*Router) Handler

func (r *Router) Handler(method, path string, handler http.Handler)

Handler is equivalent to r.Router.Handler, but traces requests.

func (*Router) HandlerFunc

func (r *Router) HandlerFunc(method, path string, handler http.HandlerFunc)

HandlerFunc is equivalent to r.Router.HandlerFunc, but traces requests.

func (*Router) OPTIONS

func (r *Router) OPTIONS(path string, handle httprouter.Handle)

OPTIONS is equivalent to r.Router.OPTIONS, but traces requests.

func (*Router) PATCH

func (r *Router) PATCH(path string, handle httprouter.Handle)

PATCH is equivalent to r.Router.PATCH, but traces requests.

func (*Router) POST

func (r *Router) POST(path string, handle httprouter.Handle)

POST is equivalent to r.Router.POST, but traces requests.

func (*Router) PUT

func (r *Router) PUT(path string, handle httprouter.Handle)

PUT is equivalent to r.Router.PUT, but traces requests.

Jump to

Keyboard shortcuts

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