Compare commits

..

1 Commits

Author SHA1 Message Date
e756a60373 feat: sentry integration
All checks were successful
arcad/emissary/pipeline/head This commit looks good
2023-10-13 14:22:28 +02:00
2 changed files with 7 additions and 9 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,16 +55,14 @@ func Main(buildDate, projectVersion, gitRef, defaultConfigPath string, commands
}
if conf.Sentry.DSN != "" {
spew.Dump(conf.Sentry)
err = sentry.Init(sentry.ClientOptions{
Dsn: conf.Sentry.DSN,
Dsn: string(conf.Sentry.DSN),
Debug: ctx.Bool("debug"),
AttachStacktrace: true,
Environment: conf.Sentry.Environment,
Environment: string(conf.Sentry.Environment),
})
if err != nil {
return errors.WithStack(err)
logger.Error(ctx.Context, "could not initialize sentry", logger.E(errors.WithStack(err)))
}
}

View File

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