This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
backend/cmd/internal/sentry.go

34 lines
578 B
Go
Raw Normal View History

2021-11-05 06:53:14 +00:00
package internal
import (
2022-09-20 16:46:47 +00:00
"os"
2021-11-05 06:53:14 +00:00
"github.com/Kichiyaki/appmode"
"github.com/getsentry/sentry-go"
"github.com/pkg/errors"
)
const (
sentryAppName = "zdam-egzamin-zawodowy-backend"
)
func InitSentry(version string) error {
2022-09-20 16:46:47 +00:00
dsn := os.Getenv("SENTRY_DSN")
if dsn == "" {
return nil
}
2021-11-05 06:53:14 +00:00
err := sentry.Init(sentry.ClientOptions{
2022-09-20 16:46:47 +00:00
Dsn: dsn,
2021-11-05 06:53:14 +00:00
Environment: appmode.Get(),
Release: sentryAppName + "@" + version,
2021-11-05 06:53:14 +00:00
Debug: false,
2022-09-20 16:46:47 +00:00
TracesSampleRate: 0.1,
2021-11-05 06:53:14 +00:00
})
if err != nil {
return errors.Wrap(err, "sentry.Init")
}
return nil
}