sentrywrapper

package module
v0.0.0-...-c62a32f Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*sentry.ClientOptions)

func WithDebug

func WithDebug(debug bool) Option

func WithEnvironment

func WithEnvironment(environment string) Option

func WithMaxBreadcrumbs

func WithMaxBreadcrumbs(max int) Option

func WithRelease

func WithRelease(release string) Option

func WithSampleRate

func WithSampleRate(rate float64) Option

func WithTracesSampleRate

func WithTracesSampleRate(rate float64) Option

type SentryWrapper

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

SentryWrapper is a wrapper around the Sentry client to simplify error reporting and context management.

func New

func New(dsn string, opts ...Option) (*SentryWrapper, error)

New initializes and returns a SentryWrapper with the provided DSN and options.

func (*SentryWrapper) AddBreadcrumb

func (sw *SentryWrapper) AddBreadcrumb(ctx context.Context, breadcrumb *sentry.Breadcrumb)

AddBreadcrumb adds a breadcrumb to the Sentry scope within the provided context.

func (*SentryWrapper) CaptureException

func (sw *SentryWrapper) CaptureException(ctx context.Context, err error, tags map[string]string) *sentry.EventID

CaptureException reports an error to Sentry using the Sentry hub within the provided context.

func (*SentryWrapper) CaptureMessage

func (sw *SentryWrapper) CaptureMessage(ctx context.Context, message string, tags map[string]string) *sentry.EventID

CaptureMessage sends a message to Sentry using the Sentry hub within the provided context.

func (*SentryWrapper) Flush

func (sw *SentryWrapper) Flush(timeout time.Duration) bool

Flush waits for all buffered events to be sent to Sentry, blocking up to the given timeout duration.

func (*SentryWrapper) GetClient

func (sw *SentryWrapper) GetClient() *sentry.Client

GetClient retrieves the underlying Sentry client.

func (*SentryWrapper) Recover

func (sw *SentryWrapper) Recover(recoveredError interface{})

Recover captures and logs a panic, ensuring it is reported to Sentry before re-panicking.

func (*SentryWrapper) SetTag

func (sw *SentryWrapper) SetTag(ctx context.Context, key, value string)

SetTag sets a key-value pair tag on the Sentry scope within the provided context.

func (*SentryWrapper) SetTags

func (sw *SentryWrapper) SetTags(ctx context.Context, tags map[string]string)

SetTags sets multiple key-value pair tags on the Sentry scope within the provided context.

func (*SentryWrapper) SetUser

func (sw *SentryWrapper) SetUser(ctx context.Context, user sentry.User)

SetUser assigns the current user to the Sentry scope within the provided context.

func (*SentryWrapper) WithContext

func (sw *SentryWrapper) WithContext(ctx context.Context) context.Context

WithContext returns a new context with a Sentry hub bound to it.

Jump to

Keyboard shortcuts

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