Disable sentry based crash reporting in probe-cli (#228)
This commit is contained in:
parent
311c30a961
commit
978cd28d88
|
@ -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,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()
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -7,11 +7,9 @@ require (
|
|||
github.com/alecthomas/kingpin v2.2.6+incompatible
|
||||
github.com/alecthomas/units v0.0.0-20201120081800-1786d5ef83d4 // indirect
|
||||
github.com/apex/log v1.9.0
|
||||
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054 // indirect
|
||||
github.com/cretz/bine v0.1.0
|
||||
github.com/dchest/siphash v1.2.2 // indirect
|
||||
github.com/fatih/color v1.10.0
|
||||
github.com/getsentry/raven-go v0.0.0-20190419175539-919484f041ea
|
||||
github.com/golang/protobuf v1.4.3 // indirect
|
||||
github.com/google/go-cmp v0.5.2
|
||||
github.com/google/martian/v3 v3.1.0
|
||||
|
|
4
go.sum
4
go.sum
|
@ -59,8 +59,6 @@ github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7
|
|||
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054 h1:uH66TXeswKn5PW5zdZ39xEwfS9an067BirqA+P4QaLI=
|
||||
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE=
|
||||
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
|
||||
|
@ -113,8 +111,6 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV
|
|||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/getsentry/raven-go v0.0.0-20190419175539-919484f041ea h1:vpAHg3H71YFc5TqRSqbhMq8Wd0kdPoQMMAeQSgnUTpg=
|
||||
github.com/getsentry/raven-go v0.0.0-20190419175539-919484f041ea/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||
|
|
Loading…
Reference in New Issue
Block a user