forked from wfarr/k8s-event-logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bugsnag.go
44 lines (39 loc) · 1006 Bytes
/
bugsnag.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
package main
import (
"fmt"
"github.com/bugsnag/bugsnag-go"
"k8s.io/client-go/pkg/api/v1"
log "github.com/Sirupsen/logrus"
)
func configureBugsnag(apiKey, releaseStage string) error {
bugsnag.Configure(bugsnag.Configuration{
APIKey: apiKey,
Logger: log.StandardLogger(),
ReleaseStage: releaseStage,
})
return nil
}
func sendEventToBugsnag(event *v1.Event) error {
if event.Type != "Normal" {
bugsnag.Notify(
fmt.Errorf("Type: %s, Reason: %s, Message: %s", event.Type, event.Reason, event.Message),
bugsnag.MetaData{
"Event": {
"Type": event.Type,
"Reason": event.Reason,
"Message": event.Message,
},
"InvolvedObject": {
"Kind": event.InvolvedObject.Kind,
"Name": event.InvolvedObject.Name,
"Namespace": event.InvolvedObject.Namespace,
"UID": event.InvolvedObject.UID,
},
"Source": {
"Component": event.Source.Component,
"Host": event.Source.Host,
},
})
}
return nil
}