diff --git a/amber/src/main/python/core/architecture/handlers/control/query_statistics_handler.py b/amber/src/main/python/core/architecture/handlers/control/query_statistics_handler.py index b9826268274..c56cb784fa4 100644 --- a/amber/src/main/python/core/architecture/handlers/control/query_statistics_handler.py +++ b/amber/src/main/python/core/architecture/handlers/control/query_statistics_handler.py @@ -28,6 +28,10 @@ class QueryStatisticsHandler(ControlHandler): async def query_statistics(self, req: EmptyRequest) -> WorkerMetricsResponse: state, state_version = self.context.state_manager.get_state_with_version() + # Refresh the cached counters before sampling them so a worker in the + # middle of a batch reports its in-progress work rather than the + # totals from the previous batch. + self.context.statistics_manager.refresh_counters() metrics = WorkerMetrics( worker_state=state, worker_statistics=self.context.statistics_manager.get_statistics(),