insights: stop aggregation counting if the context is canceled
Created by: chwarwick
In searches that generate many matches it was possible for the request to extend beyond the context cancelation because it was processing a backlog of search events. The request would eventually be marked as a timeout so this processing was wasteful. This adds a check to exit early from the counting process if the context is already canceled.
Test plan
Unit tests added. Manually verify with long running searches.