SERVER-56422 introduced operator counters for aggregate expressions using the moment of parsing of an expression to increment its counter. Since in some cases expressions are parsed multiple times during query processing, the counter value overestimates the true expression occurrence.
The goal of this task is to implement an alternative idea with more precise counter increment using the CurOp class. The idea of Charlie is to
- Add counter map to the CurOp object.
- Add APIs to CurOp to #1 increment counters and #2 transition to "parsing stats collection is over - do not track", which we can call to lock them into place once we're done the first complete parsing. e.g. in runAggregate() or FindCmd::run().
- Once in this state any requests to increment the counters won't do anything so the code will still look pretty simple from within parseExpression().
- Finally transition the stats from the CurOp object into the serverStatus counters during 'completeAndLogOperation'.