Skip to content

Commit baaa483

Browse files
mungitoperritoandf-mongodb
authored andcommitted
DOCSP-17067 Expose usage stats for agg expressions
1 parent 0be947b commit baaa483

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

source/reference/command/serverStatus.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4756,6 +4756,11 @@ metrics
47564756
"scanAndOrder" : NumberLong(<num>),
47574757
"writeConflicts" : NumberLong(<num>)
47584758
},
4759+
"operatorCounters" : {
4760+
"expressions" : {
4761+
"<command>" : Long("0")
4762+
}
4763+
},
47594764
"queryExecutor": {
47604765
"scanned" : NumberLong(<num>),
47614766
"scannedObjects" : NumberLong(<num>),
@@ -4863,6 +4868,22 @@ metrics
48634868

48644869
*New in version 4.4 (4.2.6 and 4.0.19).*
48654870

4871+
.. serverstatus:: metrics.operatorCounters
4872+
4873+
A document with a number that indicates how often
4874+
:ref:`aggregation-expression-operators` ran. For some operators, the
4875+
number reported is a multiple of the times the operator actually
4876+
ran.
4877+
4878+
To get metrics for a specific operator, such as the greater-than
4879+
operator (:expression:`$gt`), append the operator to the command:
4880+
4881+
.. code-block:: javascript
4882+
4883+
db.runCommand( { serverStatus: 1 } ).metrics.operatorCounters.expressions.$gt
4884+
4885+
.. versionadded:: 5.0
4886+
48664887
.. serverstatus:: metrics.commands
48674888

48684889
A document that reports on the use of database commands. The fields

source/release-notes/5.0.txt

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,24 @@ MongoDB 5.0 introduces the following aggregation operators:
6565
- Description
6666

6767
* - :group:`$count`
68-
- :group:`$count (aggregation accumulator) <$count>`
68+
- :group:`$count (aggregation accumulator) <$count>`
6969
provides a count of all documents when used in the existing
7070
pipeline :pipeline:`$group (aggregation) <$group>` stage and the
7171
new MongoDB 5.0 :pipeline:`$setWindowFields` stage.
7272

7373
.. note:: Disambiguation
7474

7575
The :group:`$count (aggregation accumulator) <$count>` is
76-
distinct from the :pipeline:`$count (aggregation) <$count>`
77-
pipeline stage.
76+
distinct from the :pipeline:`$count (aggregation) <$count>`
77+
pipeline stage.
7878

7979
* - :expression:`$dateAdd`
8080
- Increments a :doc:`Date </reference/method/Date>` object by a
8181
specified number of time units.
8282

8383
* - :expression:`$dateDiff`
8484
- Returns the difference between two dates.
85-
85+
8686
* - :expression:`$dateSubtract`
8787
- Decrements a :doc:`Date </reference/method/Date>` object by a
8888
specified number of time units.
@@ -359,7 +359,7 @@ the ``"disabled"`` option.
359359
``renameCollection`` Compatible with Sharded Collections
360360
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361361

362-
Starting in MongoDB 5.0, you can use the :dbcommand:`renameCollection`
362+
Starting in MongoDB 5.0, you can use the :dbcommand:`renameCollection`
363363
command to change the name of a sharded collection.
364364

365365
.. _5.0-rel-notes-shell:
@@ -374,15 +374,15 @@ The ``mongo`` shell has been deprecated in MongoDB v5.0. The
374374
replacement shell is :binary:`~bin.mongosh`. The legacy ``mongo`` shell
375375
will be removed in a future release.
376376

377-
Shell packaging also changes in MongoDB v5.0. Refer to the
377+
Shell packaging also changes in MongoDB v5.0. Refer to the
378378
:mongosh:`installation instructions </install>` for further details.
379379

380380
Shell Support for GCP and Azure KMS Providers
381381
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
382382

383383
Starting in MongoDB 5.0 (and MongoDB 4.4.5), the Google Cloud Platform
384384
KMS and Azure Key Vault are supported in both :binary:`~bin.mongosh`
385-
and the legacy :binary:`~bin.mongo` shell as
385+
and the legacy :binary:`~bin.mongo` shell as
386386
:ref:`Key Management Service (KMS) <field-level-encryption-kms>`
387387
providers for :doc:`/core/security-client-side-encryption`.
388388

@@ -442,12 +442,12 @@ Implicit Default Write Concern
442442
Audit Events
443443
~~~~~~~~~~~~
444444

445-
Starting in MongoDB 5.0, ``startup`` and ``logout`` audit action types
446-
are available in
445+
Starting in MongoDB 5.0, ``startup`` and ``logout`` audit action types
446+
are available in
447447
:doc:`System Event Audit Messages </reference/audit-message>`.
448448

449449
The ``dropCollection`` audit action type (``atype``) adds an audit
450-
event when a :ref:`view <3.4-reference-views>` is dropped.
450+
event when a :ref:`view <3.4-reference-views>` is dropped.
451451

452452
``mongosShutdownTimeoutMillisForSignaledShutdown`` Parameter
453453
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -460,10 +460,10 @@ complete before initiating a shutdown of :binary:`~bin.mongos`.
460460
Configurable ``zstd`` Compression Level
461461
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
462462

463-
MongoDB 5.0 introduces the
463+
MongoDB 5.0 introduces the
464464
:setting:`~storage.wiredTiger.engineConfig.zstdCompressionLevel`
465-
configuration file option which allows for configurable compression
466-
levels when
465+
configuration file option which allows for configurable compression
466+
levels when
467467
:setting:`~storage.wiredTiger.collectionConfig.blockCompressor` is set
468468
to ``zstd``.
469469

@@ -547,7 +547,7 @@ Previously, :dbcommand:`logRotate` would rotate the two logs together.
547547
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
548548

549549
Starting in MongoDB 5.0, :ref:`slow operation
550-
<database-profiling-specify-slowms-threshold>` log messages include a
550+
<database-profiling-specify-slowms-threshold>` log messages include a
551551
``remote`` field specifying client IP address.
552552

553553
Define Variables Using the ``let`` Option
@@ -610,10 +610,11 @@ Aggregation Metrics
610610
- :serverstatus:`metrics.commands.findAndModify.pipeline` *(Also available in 4.4.2+, 4.2.11+)*
611611
- :serverstatus:`metrics.commands.findAndModify.arrayFilters` *(Also available in 4.4.2+, 4.2.11+)*
612612
- :serverstatus:`metrics.dotsAndDollarsFields`
613+
- :serverstatus:`metrics.operatorCounters`
613614

614615
Replication Metrics
615616
- :serverstatus:`metrics.repl.reconfig.numAutoReconfigsForRemovalOfNewlyAddedFields`
616-
617+
617618
Read Concern Counters
618619
- :serverstatus:`readConcernCounters`, which reports on the
619620
:ref:`read concern level <read-concern-levels>` specified by query
@@ -726,7 +727,7 @@ Upgrade Procedures
726727
------------------
727728

728729
.. important:: Feature Compatibility Version
729-
730+
730731
To upgrade to MongoDB 5.0 from a 4.4 deployment, the 4.4 deployment
731732
must have ``featureCompatibilityVersion`` set to ``4.4``. To check
732733
the version:

0 commit comments

Comments
 (0)