Documentation
¶
Overview ¶
Package sentryx is a thin wrapper over github.com/getsentry/sentry-go that centralizes initialization, silent no-op when SENTRY_DSN is not set, capture of whatsmeow errors (via zap hook) and the Gin middleware.
Without a configured DSN, all functions become no-ops — there is no overhead and no network call is made.
Index ¶
- func CaptureError(err error, tags map[string]string)
- func CaptureErrorWithFingerprint(err error, tags map[string]string, fingerprint []string)
- func CaptureMessage(msg string, level sentry.Level, tags map[string]string)
- func CaptureMessageWithFingerprint(msg string, level sentry.Level, tags map[string]string, fingerprint []string)
- func Fingerprint(scope, msg string) []string
- func Flush(timeout time.Duration)
- func Init(cfg Config) error
- func IsEnabled() bool
- func IsExpectedNoise(msg string) bool
- func Recover()
- func RecoverWithContext(ctx context.Context)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureError ¶
CaptureError sends an error with optional tags.
func CaptureErrorWithFingerprint ¶
CaptureErrorWithFingerprint sends an error with an explicit grouping key. Use it when the message carries identifiers (phone, JID, IDs) that would otherwise open a new issue per occurrence instead of incrementing one.
func CaptureMessage ¶
CaptureMessage sends a message with a level.
func CaptureMessageWithFingerprint ¶
func CaptureMessageWithFingerprint(msg string, level sentry.Level, tags map[string]string, fingerprint []string)
CaptureMessageWithFingerprint sends a message with an explicit grouping key. Use it when the text carries identifiers (IDs, JIDs) that would otherwise open a new issue per occurrence instead of incrementing one.
func Fingerprint ¶
Fingerprint builds a stable Sentry grouping key for messages carrying identifiers. These errors interpolate message IDs, JIDs and phone numbers into the text, so using it as the issue title splits one recurring failure into hundreds of one-off issues. Groups by scope plus the message skeleton, with identifier-looking tokens replaced by a placeholder.
func Init ¶
Init initializes Sentry when a DSN is configured. Without a DSN it is a silent no-op. Init errors are only reported by the caller (log) — they do not bring down the process.
func IsEnabled ¶
func IsEnabled() bool
IsEnabled reports whether Sentry was initialized with a valid DSN.
func IsExpectedNoise ¶
IsExpectedNoise reports whether the message is a known self-recovering failure.
func Recover ¶
func Recover()
Recover must be called via defer in critical goroutines to report panics to Sentry and re-throw them to preserve the original behavior.
func RecoverWithContext ¶
RecoverWithContext is like Recover, with scope derived from ctx.