midx

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Monitor

func Monitor(opts ...MonitorOption) func(http.Handler) http.Handler

Monitor monitors HTTP requests. Each requests goes through this middleware which records basic information about it (latency, error, ...)

func Recover

func Recover(callbacks ...OnPanicFunc) func(http.Handler) http.Handler

Recover is a middleware that recover requests from panic.

func Trace

func Trace(opts ...TracerOption) func(http.Handler) http.Handler

Trace is a shortcut for NewTracer(opts...).Trace()

Types

type MonitorOption

type MonitorOption func(*monitorOptions)

MonitorOption applies option to the http monitor.

func MonitorWithHasRequestFailedFunc

func MonitorWithHasRequestFailedFunc(fct func(r *http.Request) bool) MonitorOption

MonitorWithHasRequestFailedFunc sets the function call to check whenever the request failed as the provided one.

type OnPanicFunc

type OnPanicFunc func(w http.ResponseWriter, r *http.Request, reason interface{}, stack []byte)

OnPanicFunc is the signature of the callback called each time the request panics.

type Tracer

type Tracer struct {
	// contains filtered or unexported fields
}

Tracer stores the configuration for the tracer.

func NewTracer

func NewTracer(opts ...TracerOption) *Tracer

NewTracer creates a new tracer with the provided options.

func (Tracer) Trace

func (t Tracer) Trace(opts ...TracerOption) func(http.Handler) http.Handler

Trace traces every request that goes through.

type TracerOption

type TracerOption func(o *Tracer)

TracerOption applies options to the tracer.

func TracerWithAlwaysSampler

func TracerWithAlwaysSampler() TracerOption

TracerWithAlwaysSampler sets the sampler of the tracer.

func TracerWithCallback

func TracerWithCallback(fcts ...func(r *http.Request, span *trace.Span)) TracerOption

TracerWithCallback sets function that will be called at the end of the request in the tracer.

func TracerWithNeverSampler

func TracerWithNeverSampler() TracerOption

TracerWithNeverSampler sets the sampler of the tracer.

func TracerWithProbabilitySampler

func TracerWithProbabilitySampler(fraction float64) TracerOption

TracerWithProbabilitySampler sets the sampler of the tracer.

func TracerWithSampler

func TracerWithSampler(sampler trace.Sampler) TracerOption

TracerWithSampler sets the sampler of the tracer.

Jump to

Keyboard shortcuts

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