-
Notifications
You must be signed in to change notification settings - Fork 224
/
sentry.go
41 lines (34 loc) · 866 Bytes
/
sentry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package flyerr
import "github.com/getsentry/sentry-go"
type CaptureOption func(scope *sentry.Scope)
func WithContext(key string, val interface{}) CaptureOption {
return func(scope *sentry.Scope) {
scope.SetContext(key, val)
}
}
func WithContexts(contexts map[string]interface{}) CaptureOption {
return func(scope *sentry.Scope) {
scope.SetContexts(contexts)
}
}
func WithTag(key, value string) CaptureOption {
return func(scope *sentry.Scope) {
scope.SetTag(key, value)
}
}
func CaptureException(err error, opts ...CaptureOption) {
sentry.WithScope(func(scope *sentry.Scope) {
for _, opt := range opts {
opt(scope)
}
sentry.CaptureException(err)
})
}
func CaptureMessage(msg string, opts ...CaptureOption) {
sentry.WithScope(func(scope *sentry.Scope) {
for _, opt := range opts {
opt(scope)
}
sentry.CaptureMessage(msg)
})
}