3
0
Files
corteza/pkg/sentry/sentry.go
Denis Arh 7bde98697a Corteza discovery
- It provides mappings of corteza resources(Namespaces, Modules, Records, Users) along with values to corteza discovery indexer.
- It also save recordLogs for create, update, deletion of resources.
- Extend settings to hold discovery enabled/disabled flag
- Adds URL of compose resources for namespace and record and for module still pending, added todo with notes to code
2022-02-22 17:13:59 +05:30

47 lines
1.1 KiB
Go

package sentry
import (
"github.com/getsentry/sentry-go"
"github.com/cortezaproject/corteza-server/pkg/logger"
"github.com/cortezaproject/corteza-server/pkg/options"
)
func Init(sentryOpt options.SentryOpt) error {
if sentryOpt.DSN == "" {
return nil
}
return sentry.Init(sentry.ClientOptions{
Dsn: sentryOpt.DSN,
Debug: sentryOpt.Debug,
AttachStacktrace: sentryOpt.AttachStacktrace,
SampleRate: float64(sentryOpt.SampleRate),
MaxBreadcrumbs: sentryOpt.MaxBreadcrumbs,
IgnoreErrors: nil,
BeforeSend: nil,
BeforeBreadcrumb: nil,
Integrations: nil,
Transport: nil,
ServerName: sentryOpt.ServerName,
Release: sentryOpt.Release,
Dist: sentryOpt.Dist,
Environment: sentryOpt.Environment,
})
}
func Recover() {
// Check if client is configured
if sentry.CurrentHub().Client() == nil {
// We do not have Sentry client configured, that means we do not want to
// recover from panic here as it will only suppress it
logger.Default()
return
}
if err := recover(); err != nil {
hub := sentry.CurrentHub()
hub.Recover(err)
}
}