-
Notifications
You must be signed in to change notification settings - Fork 64
/
integrations.go
51 lines (42 loc) · 978 Bytes
/
integrations.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
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"github.com/getsentry/sentry-go"
globalLogger "github.com/rs/zerolog/log"
)
type AgentIntegration interface {
IsEnabled() bool
Init() error
IsInitialized() bool
GetContext() (string, sentry.Context, error)
GetTags() (map[string]string, error)
}
func runIntegrations() error {
globalLogger.Info().Msg("Running integrations...")
scope := sentry.CurrentHub().Scope()
allIntegrations := []AgentIntegration{
GetIntegrationGKE(),
}
for _, integration := range allIntegrations {
if !integration.IsEnabled() {
continue
}
if err := integration.Init(); err != nil {
return err
}
// Process context
contextName, context, err := integration.GetContext()
if err != nil {
return err
}
scope.SetContext(contextName, context)
// Process tags
tags, err := integration.GetTags()
if err != nil {
return err
}
for tagKey, tagValue := range tags {
setTagIfNotEmpty(scope, tagKey, tagValue)
}
}
return nil
}