This repository has been archived by the owner on May 31, 2023. It is now read-only.
forked from getsentry/sentry-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (44 loc) · 1.52 KB
/
main.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
52
53
54
package main
import (
"fmt"
"log"
"github.com/Cleanshelf/sentry-go"
)
type pickleIntegration struct{}
func (pi *pickleIntegration) Name() string {
return "PickleIntegration"
}
func (pi *pickleIntegration) SetupOnce(client *sentry.Client) {
client.AddEventProcessor(pi.processor)
}
func (pi *pickleIntegration) processor(event *sentry.Event, hint *sentry.EventHint) *sentry.Event {
event.Message = fmt.Sprintf("PickleRick Says: %s", event.Message)
return event
}
func main() {
scope1 := sentry.NewScope()
client1, _ := sentry.NewClient(sentry.ClientOptions{
Dsn: "https://hello@world.io/1",
BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event {
log.Println(event.Message)
return nil
},
Integrations: func(integrations []sentry.Integration) []sentry.Integration {
return append(integrations, &pickleIntegration{})
},
})
hub1 := sentry.NewHub(client1, scope1)
scope2 := sentry.NewScope()
client2, _ := sentry.NewClient(sentry.ClientOptions{
Dsn: "https://hello@world.io/2",
BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event {
log.Println(event.Message)
return nil
},
})
hub2 := sentry.NewHub(client2, scope2)
hub1.CaptureMessage("Hub: altered message by pickleIntegration")
hub2.CaptureMessage("Hub: _NOT_ altered message by pickleIntegration")
client1.CaptureMessage("Client: altered message by pickleIntegration", &sentry.EventHint{}, scope1)
client2.CaptureMessage("Client: _NOT_ altered message by pickleIntegration", &sentry.EventHint{}, scope2)
}