sentry

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

README

Go Sentry Middleware tools

500 middlewares

Send a 500 response to Sentry.

  • gin Middleware (gin folder) MiddlewareSentry500, MiddlewareSentry500Opts
  • goa Middleware (goa folder) MiddlewareSentry500

Log sentry events that are not sent

Sentry does not provide a way to log information about what is not sent. This repo implements an http.RoundTripper that can recover and log the sentry.Event that failed to send. This is implemented in sentry.go as LogSentrySendFailures.RoundTrip

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultFingerprintErrorHandler added in v0.5.0

func DefaultFingerprintErrorHandler(err error)

func HubCustomFingerprint

func HubCustomFingerprint(hub *sentry.Hub, fingerprintErrHandler func(err error)) *sentry.Hub

func NormalizeUrlPathForSentry

func NormalizeUrlPathForSentry(url *url.URL, placeholder string) string

NormalizeUrlPathForSentry takes a url path string and replaces any path part that contains a number with a standard placeholder value. This allows for better error grouping at Sentry for urls that may contain dynamic values (UUID for example) but are basically the same URL in general

func RedactDSN added in v0.4.0

func RedactDSN(body []byte) []byte

func SentryBeforeSendUnwrapAndFilterErrorType added in v0.6.0

func SentryBeforeSendUnwrapAndFilterErrorType(conf UnwrapAndFilterErrorTypeConfig) func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event

Golang error types tend to be generic wrappers Unwrap known generic error types until we find an unrecognized error type That error type is assumed to be useful Otherwise just strip the "*errors." or "errors." prefix which adds noise

func SentryFingerprint

func SentryFingerprint(event *sentry.Event, hint *sentry.EventHint) error

group on the url and the beginning of the body. The same url can have different errors: thus looking at the response body. the longer the body is, the more likely it is to contain variable So for now try looking at a beginning snippet of the body. The URL is normalized so that any path part with a number is replaced by a placeholder value

func SlogErrHandler added in v0.5.0

func SlogErrHandler(ctx context.Context, err ErrSentryRoundTrip)

Types

type ErrSentryRoundTrip added in v0.5.0

type ErrSentryRoundTrip struct {
	Msg       string
	Err       error
	Status    int
	Request   []byte
	Exception []sentry.Exception
	Response  []byte
}

func (ErrSentryRoundTrip) Error added in v0.5.0

func (esrt ErrSentryRoundTrip) Error() string

type LogSentrySendFailures

type LogSentrySendFailures struct {
	RT           http.RoundTripper
	ErrorHandler func(context.Context, ErrSentryRoundTrip)
}

func NewLogSentrySendFailures added in v0.5.0

func NewLogSentrySendFailures(rt http.RoundTripper) LogSentrySendFailures

func (LogSentrySendFailures) RoundTrip

func (lsf LogSentrySendFailures) RoundTrip(req *http.Request) (*http.Response, error)

type SentryError500

type SentryError500 struct {
	Url  string
	Body string
}

func (SentryError500) Error

func (e500 SentryError500) Error() string

type UnwrapAndFilterErrorTypeConfig added in v0.6.0

type UnwrapAndFilterErrorTypeConfig struct {
	FilterErrorTypes []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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