[maze] Multiple events in a session
Roger Guldbrandsen
5 years ago
86 | 86 |
case "filtered":
|
87 | 87 |
filtered()
|
88 | 88 |
case "recover":
|
89 | |
recover()
|
|
89 |
dontDie()
|
90 | 90 |
case "session and error":
|
91 | 91 |
sessionAndError()
|
92 | 92 |
case "send and exit":
|
93 | 93 |
sendAndExit()
|
94 | 94 |
case "user":
|
95 | 95 |
user()
|
|
96 |
case "multiple handled":
|
|
97 |
multipleHandled()
|
|
98 |
case "multiple unhandled":
|
|
99 |
multipleUnhandled()
|
96 | 100 |
default:
|
97 | 101 |
log.Println("Not a valid test flag: " + *test)
|
98 | 102 |
os.Exit(1)
|
99 | 103 |
}
|
100 | 104 |
|
|
105 |
}
|
|
106 |
|
|
107 |
func multipleHandled() {
|
|
108 |
//Make the order of the below predictable
|
|
109 |
bugsnag.Configure(bugsnag.Configuration{Synchronous: true})
|
|
110 |
|
|
111 |
ctx := bugsnag.StartSession(context.Background())
|
|
112 |
bugsnag.Notify(fmt.Errorf("oops"), ctx)
|
|
113 |
bugsnag.Notify(fmt.Errorf("oops"), ctx)
|
|
114 |
}
|
|
115 |
|
|
116 |
func multipleUnhandled() {
|
|
117 |
//Make the order of the below predictable
|
|
118 |
notifier := bugsnag.New(bugsnag.Configuration{Synchronous: true})
|
|
119 |
notifier.FlushSessionsOnRepanic(false)
|
|
120 |
|
|
121 |
ctx := bugsnag.StartSession(context.Background())
|
|
122 |
defer func() { recover() }()
|
|
123 |
defer notifier.AutoNotify(ctx)
|
|
124 |
defer notifier.AutoNotify(ctx)
|
|
125 |
panic("oops")
|
101 | 126 |
}
|
102 | 127 |
|
103 | 128 |
func unhandledCrash() {
|
|
173 | 198 |
time.Sleep(100 * time.Millisecond)
|
174 | 199 |
}
|
175 | 200 |
|
176 | |
func recover() {
|
|
201 |
func dontDie() {
|
177 | 202 |
go func() {
|
178 | 203 |
defer bugsnag.Recover()
|
179 | 204 |
panic("Go routine killed but recovered")
|
|
0 |
Feature: Reporting multiple handled and unhandled errors in the same session
|
|
1 |
|
|
2 |
Background:
|
|
3 |
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
|
|
4 |
And I configure the bugsnag endpoint
|
|
5 |
And I have built the service "app"
|
|
6 |
And I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"
|
|
7 |
|
|
8 |
Scenario: Handled errors know about previous reported handled errors
|
|
9 |
When I run the go service "app" with the test case "multiple handled"
|
|
10 |
And I wait to receive 2 requests
|
|
11 |
And the request 0 is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
|
|
12 |
And the request 1 is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
|
|
13 |
And the event handled sessions count equals 1 for request 0
|
|
14 |
And the event handled sessions count equals 2 for request 1
|
|
15 |
|
|
16 |
Scenario: Unhandled errors know about previous reported handled errors
|
|
17 |
When I run the go service "app" with the test case "multiple unhandled"
|
|
18 |
And I wait to receive 2 requests
|
|
19 |
And the request 0 is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
|
|
20 |
And the request 1 is a valid error report with api key "a35a2a72bd230ac0aa0f52715bbdc6aa"
|
|
21 |
And the event unhandled sessions count equals 1 for request 0
|
|
22 |
And the event unhandled sessions count equals 2 for request 1
|