2020-04-16 22:12:38 +05:30
|
|
|
package di
|
|
|
|
|
|
|
|
import (
|
2023-12-13 21:59:12 +05:30
|
|
|
"github.com/defval/di"
|
2020-04-16 22:12:38 +05:30
|
|
|
"github.com/getsentry/raven-go"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
|
2024-02-01 12:42:34 +05:30
|
|
|
"ely.by/chrly/internal/version"
|
2020-04-16 22:12:38 +05:30
|
|
|
)
|
|
|
|
|
2024-02-07 22:04:57 +05:30
|
|
|
var loggerDiOptions = di.Options(
|
2020-04-16 22:12:38 +05:30
|
|
|
di.Provide(newSentry),
|
|
|
|
)
|
|
|
|
|
|
|
|
func newSentry(config *viper.Viper) (*raven.Client, error) {
|
|
|
|
sentryAddr := config.GetString("sentry.dsn")
|
|
|
|
if sentryAddr == "" {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
ravenClient, err := raven.New(sentryAddr)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
ravenClient.SetEnvironment("production")
|
|
|
|
ravenClient.SetDefaultLoggerName("sentry-watchdog-receiver")
|
|
|
|
ravenClient.SetRelease(version.Version())
|
|
|
|
|
2020-04-20 19:42:58 +05:30
|
|
|
raven.DefaultClient = ravenClient
|
|
|
|
|
2020-04-16 22:12:38 +05:30
|
|
|
return ravenClient, nil
|
|
|
|
}
|