Codebase list golang-github-bugsnag-bugsnag-go / 5f6d210
[maze] Multiple events in a session Roger Guldbrandsen 5 years ago
2 changed file(s) with 50 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
8686 case "filtered":
8787 filtered()
8888 case "recover":
89 recover()
89 dontDie()
9090 case "session and error":
9191 sessionAndError()
9292 case "send and exit":
9393 sendAndExit()
9494 case "user":
9595 user()
96 case "multiple handled":
97 multipleHandled()
98 case "multiple unhandled":
99 multipleUnhandled()
96100 default:
97101 log.Println("Not a valid test flag: " + *test)
98102 os.Exit(1)
99103 }
100104
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")
101126 }
102127
103128 func unhandledCrash() {
173198 time.Sleep(100 * time.Millisecond)
174199 }
175200
176 func recover() {
201 func dontDie() {
177202 go func() {
178203 defer bugsnag.Recover()
179204 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