MetricsCollector misbehaves when all VariantMetricInformation are processed before all BatchLoaded or AllBatchesLoaded events are de-queued.
In that case, following checks are never performed: totalBatches == servedBatches and serverVariants == totalVariants.
In that case, VariantCompleted and PushMessageCompleted events are never fired and PushMessageInformation#servedVariants counter is never equal to PushMessageInformation#totalVariants (which is why UI still shows message is Pending).
There are two solutions:
1) schedule (or somehow else trigger) collector of BatchLoaded / AllBatchesLoaded events,
2) refactor metric collection logic so that it is triggered externally in cycles until everything is processed
-
this involves new CollectTriggerQueue that is used to store a "request for metrics processing"
-
will allow us to update metrics more efficiently since one update cycle will cover not only several BatchLoaded events but also several VariantMetricInformation events
See diagram for more clarity: https://docs.google.com/drawings/d/12cUrYf7ACLYEoYsIWul2szN3lmQcYFMjjaZDq2fr9qQ/edit?usp=sharing
|