Disable sentry based crash reporting in probe-cli (#228)

This commit is contained in:
Arturo Filastò
2021-02-12 19:49:18 +01:00
committed by GitHub
parent 311c30a961
commit 978cd28d88
5 changed files with 1 additions and 81 deletions
-7
View File
@@ -5,8 +5,6 @@ import (
"io/ioutil"
"sync"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/crashreport"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/utils"
"github.com/pkg/errors"
)
@@ -43,11 +41,6 @@ func ParseConfig(b []byte) (*Config, error) {
}
c.path = utils.ConfigPath(home)
if c.Advanced.SendCrashReports == false {
log.Info("Disabling crash reporting.")
crashreport.Disabled = true
}
return &c, nil
}
@@ -1,62 +0,0 @@
package crashreport
import (
"github.com/apex/log"
"github.com/getsentry/raven-go"
)
// Disabled flag is used to globally disable crash reporting and make all the
// crash reporting logic a no-op.
var Disabled = false
var client *raven.Client
// CapturePanic is a wrapper around raven.CapturePanic that becomes a noop if
// `Disabled` is set to true.
func CapturePanic(f func(), tags map[string]string) (interface{}, string) {
if Disabled == true {
return nil, ""
}
return client.CapturePanic(f, tags)
}
// CapturePanicAndWait is a wrapper around raven.CapturePanicAndWait that becomes a noop if
// `Disabled` is set to true.
func CapturePanicAndWait(f func(), tags map[string]string) (interface{}, string) {
if Disabled == true {
return nil, ""
}
return client.CapturePanicAndWait(f, tags)
}
// CaptureError is a wrapper around raven.CaptureError
func CaptureError(err error, tags map[string]string) string {
if Disabled == true {
return ""
}
return client.CaptureError(err, tags)
}
// CaptureErrorAndWait is a wrapper around raven.CaptureErrorAndWait
func CaptureErrorAndWait(err error, tags map[string]string) string {
if Disabled == true {
return ""
}
return client.CaptureErrorAndWait(err, tags)
}
// Wait will block on sending messages to the sentry server
func Wait() {
if Disabled == false {
log.Info("sending exception backtrace")
client.Wait()
}
}
func init() {
var err error
client, err = raven.NewClient("https://cb4510e090f64382ac371040c19b2258:8448daeebfa643c289ef398f8645980b@sentry.io/1234954", nil)
if err != nil {
log.WithError(err).Error("failed to create a raven client")
}
}
+1 -6
View File
@@ -1,7 +1,6 @@
package main
import (
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/cli/app"
_ "github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/cli/autorun"
_ "github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/cli/geoip"
@@ -14,12 +13,8 @@ import (
_ "github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/cli/show"
_ "github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/cli/upload"
_ "github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/cli/version"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/crashreport"
)
func main() {
if err, _ := crashreport.CapturePanic(app.Run, nil); err != nil {
log.WithError(err.(error)).Error("panic in app.Run")
crashreport.Wait()
}
app.Run()
}