Compare commits

..

1 Commits

Author SHA1 Message Date
752f1aed02 feat: sentry integration
All checks were successful
arcad/emissary/pipeline/head This commit looks good
2023-10-13 12:30:52 +02:00
2 changed files with 9 additions and 7 deletions

View File

@ -8,10 +8,10 @@ import (
"time"
"forge.cadoles.com/Cadoles/emissary/internal/command/common"
"github.com/davecgh/go-spew/spew"
"github.com/getsentry/sentry-go"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
"gitlab.com/wpetit/goweb/logger"
)
func Main(buildDate, projectVersion, gitRef, defaultConfigPath string, commands ...*cli.Command) {
@ -55,14 +55,16 @@ func Main(buildDate, projectVersion, gitRef, defaultConfigPath string, commands
}
if conf.Sentry.DSN != "" {
spew.Dump(conf.Sentry)
err = sentry.Init(sentry.ClientOptions{
Dsn: string(conf.Sentry.DSN),
Dsn: conf.Sentry.DSN,
Debug: ctx.Bool("debug"),
AttachStacktrace: true,
Environment: string(conf.Sentry.Environment),
Environment: conf.Sentry.Environment,
})
if err != nil {
logger.Error(ctx.Context, "could not initialize sentry", logger.E(errors.WithStack(err)))
return errors.WithStack(err)
}
}

View File

@ -5,14 +5,14 @@ import (
)
type SentryConfig struct {
DSN InterpolatedString `yaml:"dsn"`
Environment InterpolatedString `yaml:"environment"`
DSN string `yaml:"dsn"`
Environment string `yaml:"environment"`
}
func NewDefaultSentryConfig() SentryConfig {
hostname, _ := os.Hostname()
return SentryConfig{
DSN: "",
Environment: InterpolatedString(hostname),
Environment: hostname,
}
}