Skip to content

Commit

Permalink
cmd/stcrashreceiver: Propagate synthetic user ID for crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
calmh committed Oct 14, 2023
1 parent 483ecad commit d4c2acf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions cmd/stcrashreceiver/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type sentryService struct {

type sentryRequest struct {
reportID string
userID string
data []byte
}

Expand All @@ -52,7 +53,7 @@ func (s *sentryService) Serve(ctx context.Context) {
log.Println("Failed to parse crash report:", err)
continue
}
if err := sendReport(s.dsn, pkt, req.reportID); err != nil {
if err := sendReport(s.dsn, pkt, req.userID); err != nil {
log.Println("Failed to send crash report:", err)
}

Expand All @@ -62,9 +63,9 @@ func (s *sentryService) Serve(ctx context.Context) {
}
}

func (s *sentryService) Send(reportID string, data []byte) bool {
func (s *sentryService) Send(reportID, userID string, data []byte) bool {
select {
case s.inbox <- sentryRequest{reportID, data}:
case s.inbox <- sentryRequest{reportID, userID, data}:
return true
default:
return false
Expand Down
2 changes: 1 addition & 1 deletion cmd/stcrashreceiver/stcrashreceiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (r *crashReceiver) servePut(reportID string, w http.ResponseWriter, req *ht
}

// Send the report to Sentry
if !r.sentry.Send(reportID, bs) {
if !r.sentry.Send(reportID, userIDFor(req), bs) {
log.Println("Failed to send report to sentry (queue full):", reportID)
}
}

0 comments on commit d4c2acf

Please sign in to comment.