-
Notifications
You must be signed in to change notification settings - Fork 13
/
sentry.go
40 lines (33 loc) · 1.05 KB
/
sentry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package registry
import (
"github.com/sarulabs/di"
"github.com/coretrix/hitrix/service"
"github.com/coretrix/hitrix/service/component/app"
"github.com/coretrix/hitrix/service/component/config"
"github.com/coretrix/hitrix/service/component/sentry"
)
func ServiceProviderSentry(tracesSampleRate *float64) *service.DefinitionGlobal {
return &service.DefinitionGlobal{
Name: service.SentryService,
Build: func(ctn di.Container) (interface{}, error) {
configService := ctn.Get(service.ConfigService).(config.IConfig)
if configService == nil {
panic("`config is nil")
}
backendVersionFinal := ""
backendVersion, ok := configService.String("backend_version")
if ok {
backendVersionFinal = backendVersion
}
dsn, ok := configService.String("sentry.dsn")
if !ok {
panic("required config value sentry.dsn missing")
}
appService := ctn.Get(service.AppService).(*app.App)
if appService == nil {
panic("`app is nil")
}
return sentry.Init(dsn, appService.Mode, backendVersionFinal, tracesSampleRate), nil
},
}
}