Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-10546

Docs for SERVER-4786: Random sampling for profiling and logging



    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.5.3
    • None


      Documentation Request Summary:

      Engineering Ticket Description:

      Add a new sampleRate parameter to the profile command. This parameter can take values on the interval [0, 1], and is set to 1 by default on startup. The behavior of sampleRate is as follows for logging:

      • If the logLevel is 0, then we log a slow command that exceeds the slowms with probability given by sampleRate. Commands whose latency is less than slowms, as before, are not logged.
      • If the logLevel is 1 or higher, then all commands are logged. The sampleRate has no affect in this case.

      For creating system.profile entries, the behavior of sampleRate is as follows:

      • If the profiling level is 0, then no profile entries are created and sampleRate takes no affect.
      • If the profiling level is 1, then an operation exceeding slowms is profiled with probability given by sampleRate.
      • If the profiling level is 2, then all operations are profiled with probability given by sampleRate, regardless of latency.

      There are three ways to set the profiler sampleRate. The first is by running the profile command. For example, the following command indicates that the server should profile 10% of operations slower than 30ms:

      db.runCommand({profile: 2, slowms: 30, sampleRate: 0.1});

      This command will return the previous settings of profile, slowms, and sampleRate on success. Like slowms, the sampleRate setting is unchanged when it is omitted from the command. The sampleRate can also be set from the shell using the db.setProfilingLevel() helper:

      db.setProfilingLevel(2, {slowms: 30, sampleRate: 0.1});

      The second argument to this helper is now either the slowms value, or an options object.

      The second way to set sampleRate is the new slowOpSampleRate command line option:

      ./mongod --profile 2 --slowms 30 --slowOpSampleRate 0.1

      Third, it can be set in a configuration file using operationProfiling.slowOpSampleRate.


        Issue Links



              nick.larew@mongodb.com Nicholas Larew
              emily.hall Emily Hall
              Nicholas Larew Nicholas Larew
              0 Vote for this issue
              2 Start watching this issue


                4 years, 30 weeks, 6 days ago