-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrequests.go
47 lines (41 loc) · 1.18 KB
/
requests.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
package main
import (
"fmt"
"github.com/getsentry/sentry-go"
"math/rand"
"time"
)
type Requests struct {
events []Event
}
// TODO in each case met, check if len(config.Destinations.Platform) != 0
// Doing each destination one-by-one, gives each org a rest before its API is called again, so don't insert a short Sleep Timeout yet
func (r *Requests) send() {
var found bool
for _, event := range r.events {
for _, platform := range platforms {
found = false
if platform == event.Platform {
found = true
for _, dsn := range config.Destinations[platform] {
// Randomize how many times the request is sent, for burst volume
for i := 0; i <= rand.Intn(4); i++ {
time.Sleep(200 * time.Millisecond)
event.setDsn(dsn)
event.Error.eventId() // can't send same eventId twice
request := NewRequest(event)
request.send()
}
}
break
}
}
if found == false {
sentry.CaptureMessage("unsupported event platform: " + event.Platform)
fmt.Printf("\nunrecognized Platform %v\n", event.Platform)
}
}
fmt.Printf("\n> TOTAL sent: %v", counter)
// Does not Capture, not sure why
sentry.CaptureMessage("finished sending all requests")
}