Documentation ¶
Overview ¶
Package apmfasthttp provides a tracing middleware fasthttp.RequestHandler for servers.
Index ¶
- func ServerRequestName(ctx *fasthttp.RequestCtx) string
- func StartTransactionWithBody(ctx *fasthttp.RequestCtx, tracer *apm.Tracer, name string) (*apm.Transaction, *apm.BodyCapturer, error)
- func Wrap(handler fasthttp.RequestHandler, options ...ServerOption) fasthttp.RequestHandler
- type RecoveryFunc
- type RequestIgnorerFunc
- type RequestNameFunc
- type ServerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServerRequestName ¶
func ServerRequestName(ctx *fasthttp.RequestCtx) string
ServerRequestName returns the transaction name for the server request context, ctx.
func StartTransactionWithBody ¶
func StartTransactionWithBody( ctx *fasthttp.RequestCtx, tracer *apm.Tracer, name string, ) (*apm.Transaction, *apm.BodyCapturer, error)
StartTransactionWithBody returns a new Transaction with name, created with tracer, and taking trace context from ctx.
If the transaction is not ignored, the request and the request body capturer will be returned with the transaction added to its context.
func Wrap ¶
func Wrap(handler fasthttp.RequestHandler, options ...ServerOption) fasthttp.RequestHandler
Wrap returns a fasthttp.RequestHandler wrapping handler, reporting each request as a transaction to Elastic APM.
By default, the returned RequestHandler will use apm.DefaultTracer(). Use WithTracer to specify an alternative tracer.
By default, the returned RequestHandler will recover panics, reporting them to the configured tracer. To override this behaviour, use WithRecovery.
Types ¶
type RecoveryFunc ¶
type RecoveryFunc func(ctx *fasthttp.RequestCtx, tx *apm.Transaction, bc *apm.BodyCapturer, recovered interface{})
RecoveryFunc is the type of a function for use in WithRecovery.
func NewTraceRecovery ¶
func NewTraceRecovery(t *apm.Tracer) RecoveryFunc
NewTraceRecovery returns a RecoveryFunc for use in WithRecovery.
The returned RecoveryFunc will report recovered error to Elastic APM using the given Tracer, or apm.DefaultTracer() if t is nil. The error will be linked to the given transaction.
If headers have not already been written, a 500 response will be sent.
type RequestIgnorerFunc ¶
type RequestIgnorerFunc func(*fasthttp.RequestCtx) bool
RequestIgnorerFunc is the type of a function for use in WithServerRequestIgnorer.
func NewDynamicServerRequestIgnorer ¶
func NewDynamicServerRequestIgnorer(t *apm.Tracer) RequestIgnorerFunc
NewDynamicServerRequestIgnorer returns the RequestIgnorer to use in handler. The list of wildcard patterns comes from central config
type RequestNameFunc ¶
type RequestNameFunc func(*fasthttp.RequestCtx) string
RequestNameFunc is the type of a function for use in WithServerRequestName.
type ServerOption ¶
type ServerOption func(*apmHandler)
ServerOption sets options for tracing server requests.
func WithPanicPropagation ¶
func WithPanicPropagation() ServerOption
WithPanicPropagation returns a ServerOption which enable panic propagation. Any panic will be recovered and recorded as an error in a transaction, then panic will be caused again.
func WithRecovery ¶
func WithRecovery(r RecoveryFunc) ServerOption
WithRecovery returns a ServerOption which sets r as the recovery function to use for tracing server requests.
func WithServerRequestIgnorer ¶
func WithServerRequestIgnorer(fn RequestIgnorerFunc) ServerOption
WithServerRequestIgnorer returns a ServerOption which sets fn as the function to use to determine whether or not a server request should be ignored. If request ignorer is nil, all requests will be reported.
func WithServerRequestName ¶
func WithServerRequestName(fn RequestNameFunc) ServerOption
WithServerRequestName returns a ServerOption which sets fn as the function to use to obtain the transaction name for the given server request.
func WithTracer ¶
func WithTracer(t *apm.Tracer) ServerOption
WithTracer returns a ServerOption which sets t as the tracer to use for tracing server requests.