-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Added manual test for concurrent setters
- Loading branch information
1 parent
50a4841
commit b1d347b
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ script: | |
- golangci-lint run | ||
- go build | ||
- go test | ||
- go test -race | ||
|
||
notifications: | ||
webhooks: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/getsentry/sentry-go" | ||
) | ||
|
||
func main() { | ||
i := 0 | ||
|
||
if err := sentry.Init(sentry.ClientOptions{ | ||
Dsn: "", | ||
BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event { | ||
i++ | ||
if i%1000 == 0 { | ||
fmt.Println(i) | ||
} | ||
return nil | ||
}, | ||
}); err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
for i := 0; i < 10000; i++ { | ||
go func(x int) { | ||
sentry.WithScope(func(scope *sentry.Scope) { | ||
scope.SetTag("foo", "bar") | ||
scope.SetContext("foo", "bar") | ||
scope.SetExtra("foo", "bar") | ||
scope.SetLevel(sentry.LevelDebug) | ||
scope.SetTransaction("foo") | ||
scope.SetFingerprint([]string{"foo"}) | ||
scope.AddBreadcrumb(&sentry.Breadcrumb{Timestamp: 1337, Message: "foo"}, 100) | ||
scope.SetUser(sentry.User{ID: "foo"}) | ||
scope.SetRequest(sentry.Request{URL: "foo"}) | ||
|
||
sentry.CaptureException(errors.New(string(x))) | ||
}) | ||
}(i) | ||
|
||
go func(x int) { | ||
sentry.ConfigureScope(func(scope *sentry.Scope) { | ||
scope.SetTag("foo", "bar") | ||
scope.SetContext("foo", "bar") | ||
scope.SetExtra("foo", "bar") | ||
scope.SetLevel(sentry.LevelDebug) | ||
scope.SetTransaction("foo") | ||
scope.SetFingerprint([]string{"foo"}) | ||
scope.AddBreadcrumb(&sentry.Breadcrumb{Timestamp: 1337, Message: "foo"}, 100) | ||
scope.SetUser(sentry.User{ID: "foo"}) | ||
scope.SetRequest(sentry.Request{URL: "foo"}) | ||
|
||
sentry.CaptureException(errors.New(string(x))) | ||
}) | ||
}(i) | ||
} | ||
|
||
for i := 0; i < 10000; i++ { | ||
func(x int) { | ||
sentry.WithScope(func(scope *sentry.Scope) { | ||
scope.SetTag("foo", "bar") | ||
scope.SetContext("foo", "bar") | ||
scope.SetExtra("foo", "bar") | ||
scope.SetLevel(sentry.LevelDebug) | ||
scope.SetTransaction("foo") | ||
scope.SetFingerprint([]string{"foo"}) | ||
scope.AddBreadcrumb(&sentry.Breadcrumb{Timestamp: 1337, Message: "foo"}, 100) | ||
scope.SetUser(sentry.User{ID: "foo"}) | ||
scope.SetRequest(sentry.Request{URL: "foo"}) | ||
|
||
sentry.CaptureException(errors.New(string(x))) | ||
}) | ||
}(i) | ||
|
||
func(x int) { | ||
sentry.ConfigureScope(func(scope *sentry.Scope) { | ||
scope.SetTag("foo", "bar") | ||
scope.SetContext("foo", "bar") | ||
scope.SetExtra("foo", "bar") | ||
scope.SetLevel(sentry.LevelDebug) | ||
scope.SetTransaction("foo") | ||
scope.SetFingerprint([]string{"foo"}) | ||
scope.AddBreadcrumb(&sentry.Breadcrumb{Timestamp: 1337, Message: "foo"}, 100) | ||
scope.SetUser(sentry.User{ID: "foo"}) | ||
scope.SetRequest(sentry.Request{URL: "foo"}) | ||
|
||
sentry.CaptureException(errors.New(string(x))) | ||
}) | ||
}(i) | ||
} | ||
|
||
// wait for goroutines to finish | ||
time.Sleep(time.Second) | ||
} |