Add sentry init
This commit is contained in:
parent
e62c35b2db
commit
db74b79498
|
@ -59,6 +59,7 @@ import (
|
||||||
"code.vikunja.io/api/pkg/routes/caldav"
|
"code.vikunja.io/api/pkg/routes/caldav"
|
||||||
_ "code.vikunja.io/api/pkg/swagger" // To generate swagger docs
|
_ "code.vikunja.io/api/pkg/swagger" // To generate swagger docs
|
||||||
"code.vikunja.io/api/pkg/user"
|
"code.vikunja.io/api/pkg/user"
|
||||||
|
"code.vikunja.io/api/pkg/version"
|
||||||
"code.vikunja.io/web"
|
"code.vikunja.io/web"
|
||||||
"code.vikunja.io/web/handler"
|
"code.vikunja.io/web/handler"
|
||||||
"github.com/asaskevich/govalidator"
|
"github.com/asaskevich/govalidator"
|
||||||
|
@ -67,6 +68,7 @@ import (
|
||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
elog "github.com/labstack/gommon/log"
|
elog "github.com/labstack/gommon/log"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CustomValidator is a dummy struct to use govalidator with echo
|
// CustomValidator is a dummy struct to use govalidator with echo
|
||||||
|
@ -118,12 +120,17 @@ func NewEcho() *echo.Echo {
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.ServiceSentryDsn.GetString() != "" {
|
if config.ServiceSentryDsn.GetString() != "" {
|
||||||
|
if err := sentry.Init(sentry.ClientOptions{
|
||||||
|
Dsn: config.ServiceSentryDsn.GetString(),
|
||||||
|
AttachStacktrace: true,
|
||||||
|
Release: version.Version,
|
||||||
|
}); err != nil {
|
||||||
|
log.Criticalf("Sentry init failed: %s", err)
|
||||||
|
}
|
||||||
|
defer sentry.Flush(5 * time.Second)
|
||||||
|
|
||||||
e.HTTPErrorHandler = func(err error, c echo.Context) {
|
e.HTTPErrorHandler = func(err error, c echo.Context) {
|
||||||
|
sentry.CaptureException(err)
|
||||||
sentry.Init(sentry.ClientOptions{
|
|
||||||
Dsn: config.ServiceSentryDsn.GetString(),
|
|
||||||
})
|
|
||||||
|
|
||||||
e.DefaultHTTPErrorHandler(err, c)
|
e.DefaultHTTPErrorHandler(err, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user