Skip to content

Commit

Permalink
Give up on remaining analytics messages when we fail to push to the b…
Browse files Browse the repository at this point in the history
…uffer (#1351)

* Give up on remaining analytics messages when we fail to push to the buffer. Log how many messages were in there

* Build some more information about the message types we're overloaded with
  • Loading branch information
thomshutt authored Jul 30, 2024
1 parent e21d85a commit 19a04f7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions handlers/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,20 @@ func (c *AnalyticsHandlersCollection) Log() httprouter.Handle {
cerrors.WriteHTTPBadRequest(w, "Invalid playback_id", nil)
}

for _, ad := range c.toAnalyticsData(log, geo, extData) {
data := c.toAnalyticsData(log, geo, extData)
for i, ad := range data {
select {
case dataCh <- ad:
// process data async
default:
glog.Warningf("error processing analytics log, too many requests")
// Do some counting up of the different message types to give us a better picture of what's going on here
msgTypes := map[string]int{}
for _, msg := range data {
msgTypes[msg.EventType] += 1
}
glog.Warningf("error processing analytics log, too many requests. Failed to write %d lines. Message types: %v", len(data)-i, msgTypes)
cerrors.WriteHTTPInternalServerError(w, "error processing analytics log, too many requests", nil)
return
}
}
}
Expand Down

0 comments on commit 19a04f7

Please sign in to comment.