Skip to content

sampleRate is global #3206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions source/tutorial/manage-the-database-profiler.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ Profile a Random Sample of Slow Operations

.. versionadded:: 3.6

To profile only a randomly sampled subset of all *slow* operations on a
specific database, specify the desired sample rate in one of the following ways:
To profile only a randomly sampled subset of all *slow* operations, specify the
desired sample rate in one of the following ways:

- Set the value of ``sampleRate`` using the :dbcommand:`profile` command
or :method:`db.setProfilingLevel()` shell helper method.
Expand All @@ -135,9 +135,9 @@ specific database, specify the desired sample rate in one of the following ways:
:ref:`configuration file <configuration-options>`.

By default, ``sampleRate`` is set to ``1.0``, meaning all *slow*
operations are profiled. Databases with a ``sampleRate`` between 0 and 1
will only profile a randomly sampled percentage of *slow* operations
according to ``sampleRate``.
operations are profiled. When ``sampleRate`` is set between 0 and 1
databases with profiling level ``1`` will only profile a randomly sampled
percentage of *slow* operations according to ``sampleRate``.

For example, the following method sets the profiling level for the
current database to ``1`` and sets the profiler to sample 42% of all *slow* operations:
Expand All @@ -146,6 +146,11 @@ current database to ``1`` and sets the profiler to sample 42% of all *slow* oper

db.setProfilingLevel(1, { sampleRate: 0.42 })

.. important::
The sample rate value applies to all databases in a
:binary:`~bin.mongod` instance. It is used by both the database profiler
and the system log

.. important::
.. include:: /includes/fact-log-slow-queries.rst

Expand Down