trackers

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: Apache-2.0 Imports: 4 Imported by: 7

Documentation

Index

Constants

View Source
const (
	TraceStackDepth = 128
)

Variables

This section is empty.

Functions

func NewContextWithCapturer

func NewContextWithCapturer(ctx context.Context, c Capturer) context.Context

Types

type Capturer

type Capturer interface {
	// WithNewTrace causes any captures to automatically get a stack trace
	// associated to them.
	WithNewTrace() Capturer

	// WithAppPackages causes the listed packages (and any child packages) to be
	// highlighted as part of the current application in stack traces.
	WithAppPackages(packages []string) Capturer

	// WithUser adds the given user information to any errors reported.
	WithUser(u User) Capturer

	// WithTags adds the given tags to any errors reported.
	WithTags(tags ...Tag) Capturer

	// Try runs the given function, and if a panic occurs, captures and reports
	// it. It returns the recovered value of the panic, or nil if no panic
	// occurred.
	//
	// The context received by the callback will have this capturer bound to it.
	Try(ctx context.Context, fn func(ctx context.Context)) interface{}

	// Capture captures the given error for reporting.
	Capture(err error) Reporter

	// CaptureMessage converts the given message to an error and captures it.
	CaptureMessage(message string) Reporter

	// Middleware returns an HTTP middleware configured for this capturer.
	Middleware() Middleware
}

func CapturerFromContext

func CapturerFromContext(ctx context.Context) (c Capturer, ok bool)

func MustCapturerFromContext

func MustCapturerFromContext(ctx context.Context) Capturer

type Middleware

type Middleware interface {
	WithTags(tags ...Tag) Middleware
	WithUser(u User) Middleware

	Wrap(target http.Handler) http.Handler
}

type Reporter

type Reporter interface {
	// WithNewTrace adds a stack trace at the error location to the report.
	WithNewTrace() Reporter

	// WithTrace adds the given stack trace to the report.
	WithTrace(t *Trace) Reporter

	// WithTags adds the given tags to this error report.
	WithTags(tags ...Tag) Reporter

	// AsWarning reduces the severity of this error to a warning.
	AsWarning() Reporter

	// Report submits this error to the reporting service asynchronously.
	Report(ctx context.Context) <-chan error

	// ReportSync submits this error to the reporting service and waits for a
	// response.
	ReportSync(ctx context.Context) error
}

type Tag

type Tag struct {
	Key, Value string
}

type Trace

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

func NewTrace

func NewTrace(skip int) *Trace

func (*Trace) Frames

func (t *Trace) Frames() *runtime.Frames

type User

type User struct {
	ID    string
	Email string
}

Jump to

Keyboard shortcuts

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