sentry/sentry_echo.go

31 lines
597 B
Go

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{
Dsn: cfg.Dsn,
Environment: cfg.Env,
}); 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
}