diff options
author | Evan Broder <evan@stripe.com> | 2016-07-05 21:02:49 -0700 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2017-01-26 18:35:29 -0500 |
commit | 94b37aac060bcc8b10c3eb41f178d84008136f9c (patch) | |
tree | f98c9f60273345ea880af48ab14ad7ac8ef167cd /src/mongo/db/mongod_options.cpp | |
parent | 249eaae3e1b78ed5c4b6b7425145a23dc658fd75 (diff) | |
download | mongo-94b37aac060bcc8b10c3eb41f178d84008136f9c.tar.gz |
SERVER-4786 Allow specifying sample rate of slow queries
Adds a sampleRate parameter to the profile command, a value
on the interval [0, 1] which indicates which fraction of
operations should be randomly sampled for profiling and
logging. This allows users to reduce their slowms threshold
or increase their profiling level with less performance
impact on the system.
Closes #1099
Signed-off-by: David Storch <david.storch@10gen.com>
Diffstat (limited to 'src/mongo/db/mongod_options.cpp')
-rw-r--r-- | src/mongo/db/mongod_options.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp index 921de16e082..3824340a934 100644 --- a/src/mongo/db/mongod_options.cpp +++ b/src/mongo/db/mongod_options.cpp @@ -146,6 +146,13 @@ Status addMongodOptions(moe::OptionSection* options) { "value of slow for profile and console log") .setDefault(moe::Value(100)); + general_options + .addOptionChaining("operationProfiling.slowOpSampleRate", + "slowOpSampleRate", + moe::Double, + "fraction of slow ops to include in the profile and console log") + .setDefault(moe::Value(1.0)); + general_options.addOptionChaining("profile", "profile", moe::Int, "0=off 1=slow, 2=all") .setSources(moe::SourceAllLegacy); @@ -1044,6 +1051,10 @@ Status storeMongodOptions(const moe::Environment& params) { serverGlobalParams.slowMS = params["operationProfiling.slowOpThresholdMs"].as<int>(); } + if (params.count("operationProfiling.slowOpSampleRate")) { + serverGlobalParams.sampleRate = params["operationProfiling.slowOpSampleRate"].as<double>(); + } + if (params.count("storage.syncPeriodSecs")) { storageGlobalParams.syncdelay = params["storage.syncPeriodSecs"].as<double>(); if (storageGlobalParams.syncdelay < 0 || |