@@ -3312,6 +3312,11 @@ metrics
33123312 "scanAndOrder" : NumberLong(<num>),
33133313 "writeConflicts" : NumberLong(<num>)
33143314 },
3315+ "operatorCounters" : {
3316+ "match" : {
3317+ "<command>" : Long(<num>)
3318+ }
3319+ },
33153320 "queryExecutor": {
33163321 "scanned" : NumberLong(<num>),
33173322 "scannedObjects" : NumberLong(<num>)
@@ -3398,6 +3403,37 @@ metrics
33983403
33993404 *New in version 4.2.6 (and 4.0.19).*
34003405
3406+ .. serverstatus:: metrics.operatorCounters.match
3407+
3408+ A document with a number that indicates how often
3409+ :ref:`match expressions <query-projection-operators-top>` ran. For
3410+ some operators, the number reported is a multiple of the times the
3411+ operator actually ran.
3412+
3413+ :ref:`Match expression operators <query-projection-operators-top>`
3414+ also increment as part of an aggregation pipeline :pipeline:`$match`
3415+ stage. If the ``$match`` stage uses the :query:`$expr` operator, the
3416+ counter for ``$expr`` increments, but the component counters do not
3417+ increment.
3418+
3419+ Consider the following query:
3420+
3421+ .. code-block:: javascript
3422+ :copyable: false
3423+
3424+ db.matchCount.aggregate(
3425+ [
3426+ { $match:
3427+ { $expr: { $gt: [ "$_id", 0 ] } }
3428+ }
3429+ ]
3430+ )
3431+
3432+ The counter for ``$expr`` increments when the query runs. The
3433+ counter for ``$gt`` does not.
3434+
3435+ .. versionadded:: 4.2.18
3436+
34013437.. serverstatus:: metrics.commands
34023438
34033439 A document that reports on the use of database commands. The fields
0 commit comments