-
Notifications
You must be signed in to change notification settings - Fork 13
/
sentry.go
53 lines (42 loc) · 1.09 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
package sentry
import (
"context"
"time"
"github.com/getsentry/sentry-go"
)
type ISentry interface {
CaptureMessage(message string)
CaptureException(exception error)
Flush(timeout time.Duration)
StartSpan(ctx context.Context, operation string, options ...sentry.SpanOption) *sentry.Span
}
type v struct {
}
func Init(dsn, mode, release string, tracesSampleRate *float64) ISentry {
tracesSampleRateValue := 0.0
if tracesSampleRate != nil {
tracesSampleRateValue = *tracesSampleRate
}
err := sentry.Init(sentry.ClientOptions{
Dsn: dsn,
TracesSampleRate: tracesSampleRateValue,
Release: release,
Environment: mode,
})
if err != nil {
panic(err)
}
return &v{}
}
func (v *v) CaptureMessage(message string) {
sentry.CaptureMessage(message)
}
func (v *v) CaptureException(exception error) {
sentry.CaptureException(exception)
}
func (v *v) Flush(timeout time.Duration) {
sentry.Flush(timeout)
}
func (v *v) StartSpan(ctx context.Context, operation string, options ...sentry.SpanOption) *sentry.Span {
return sentry.StartSpan(ctx, operation, options...)
}