Skip to content

Commit d7c93c6

Browse files
committed
do not overwrite transport
the SyncTransport breaks sentry.Flush()
1 parent 22f3a6f commit d7c93c6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sentry.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ type (
2727
}
2828
)
2929

30+
var SentryTimeout = 30 * time.Second
31+
3032
// newReporter creates a new Sentry client
3133
func newReporter(cr *CmdRequest) (*Reporter, error) {
3234
sentryDSN, ok := os.LookupEnv("CRONGUARD_SENTRY_DSN")
@@ -53,8 +55,7 @@ func newReporter(cr *CmdRequest) (*Reporter, error) {
5355

5456
// setup sentry
5557
sentryErr := sentry.Init(sentry.ClientOptions{
56-
Dsn: sentryDSN,
57-
Transport: sentry.NewHTTPSyncTransport(),
58+
Dsn: sentryDSN,
5859
})
5960
if sentryErr != nil {
6061
fmt.Fprintf(cr.Status.Stderr, "cronguard: unable to connect to sentry: %s\n", sentryErr)
@@ -104,9 +105,9 @@ type reportLevel = string
104105

105106
const (
106107
// infoLevel is an information that will be send to sentry
107-
infoLevel reportLevel = "info"
108+
infoLevel reportLevel = "info"
108109
// finishLevel is used to tell the reporter that the cron has finished
109-
finishLevel = "finish"
110+
finishLevel = "finish"
110111
)
111112

112113
// report reports any error message to sentry
@@ -133,7 +134,7 @@ func (r *Reporter) report(err error, level reportLevel) error {
133134
_ = sentry.CaptureMessage(name)
134135

135136
// hide error if messages are successfully flushed to sentry
136-
flushed := sentry.Flush(30 * time.Second)
137+
flushed := sentry.Flush(SentryTimeout)
137138
if !flushed {
138139
return err
139140
}

0 commit comments

Comments
 (0)