Documentation
¶
Overview ¶
Package sentrytools contains all sorts of tools for using Sentry.
Index ¶
- func GoRoutineWrapper(ctx context.Context, logger *slog.Logger, name string, ...)
- func Init(env string, options sentry.ClientOptions) (*sentry.Hub, error)
- func Middleware(env string) (helpers.Middleware, error)
- func MockedHubEvents(hub *sentry.Hub) []*sentry.Event
- func MockedSentryClientOptions() sentry.ClientOptions
- func MockedSentryHub() *sentry.Hub
- func NewLogHandler(env string, handler slog.Handler) slog.Handler
- type LogHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoRoutineWrapper ¶
func GoRoutineWrapper( ctx context.Context, logger *slog.Logger, name string, f func(ctx context.Context, logger *slog.Logger) error, )
GoRoutineWrapper wraps a go routine with Sentry logic for error and performance tracking.
func Init ¶
Init initializes Sentry and returns a hub clone suitable for use on background contexts (e.g. job queues). Returns nil, nil when the DSN is empty or env is config.TestEnv — in those cases no initialization is performed and Middleware() handles its own setup. Must be called before Middleware().
func Middleware ¶
func Middleware(env string) (helpers.Middleware, error)
Middleware is middleware used to configure and enable Sentry. Call Init at application startup before using this middleware. When env is config.TestEnv, a mocked sentry.Hub will be used and Sentry is self-initialized with mock options.
func MockedHubEvents ¶
MockedHubEvents returns events captured by a hub created via MockedSentryHub.
func MockedSentryClientOptions ¶
func MockedSentryClientOptions() sentry.ClientOptions
MockedSentryClientOptions returns a mocked version of sentry.ClientOptions.
func MockedSentryHub ¶
MockedSentryHub returns a mocked version of *sentry.Hub.
Types ¶
type LogHandler ¶
type LogHandler struct {
// contains filtered or unexported fields
}
LogHandler is used for capturing logs and sending these to Sentry.
func (*LogHandler) Enabled ¶
Enabled checks if logs are enabled in a LogHandler for a certain slog.Level.
func (*LogHandler) Handle ¶
Handle handles a slog.Record by a [SentryLogHandler].