add basic support for sentry error reporting (#5410)

This commit is contained in:
Nikita Korolev
2024-03-22 17:10:57 +03:00
committed by GitHub
parent 61f4e40ad9
commit 953f571349
3 changed files with 21 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import (
"strings"
"sync"
"text/template"
"time"
"unicode"
"unicode/utf8"
@@ -16,6 +17,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/util"
flag "github.com/seaweedfs/seaweedfs/weed/util/fla9"
"github.com/getsentry/sentry-go"
"github.com/seaweedfs/seaweedfs/weed/command"
"github.com/seaweedfs/seaweedfs/weed/glog"
)
@@ -49,6 +51,19 @@ func main() {
glog.MaxFileCount = 5
flag.Usage = usage
err := sentry.Init(sentry.ClientOptions{
SampleRate: 0.1,
EnableTracing: true,
TracesSampleRate: 0.1,
ProfilesSampleRate: 0.1,
})
if err != nil {
fmt.Fprintf(os.Stderr, "sentry.Init: %v", err)
}
// Flush buffered events before the program terminates.
// Set the timeout to the maximum duration the program can afford to wait.
defer sentry.Flush(2 * time.Second)
if command.AutocompleteMain(commands) {
return
}