2022-12-15 04:39:25 +00:00
|
|
|
package sentry
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/getsentry/sentry-go"
|
|
|
|
sentryecho "github.com/getsentry/sentry-go/echo"
|
|
|
|
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
)
|
|
|
|
|
|
|
|
func WithEcho(e *echo.Echo, cfg Config) error {
|
|
|
|
if err := cfg.validate(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := sentry.Init(sentry.ClientOptions{
|
2022-12-15 07:18:01 +00:00
|
|
|
Dsn: cfg.Dsn,
|
|
|
|
ServerName: cfg.ServerName,
|
2022-12-15 04:39:25 +00:00
|
|
|
}); err != nil {
|
|
|
|
fmt.Printf("[sentry] initialization failed: %s \n", err.Error())
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("⚡️[sentry]: initialization successfully with dsn: %s \n", cfg.Dsn)
|
|
|
|
|
|
|
|
e.Use(sentryecho.New(sentryecho.Options{}))
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|