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/bson/util/bson_extract.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/bson/util/bson_extract.cpp')
-rw-r--r-- | src/mongo/bson/util/bson_extract.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/bson/util/bson_extract.cpp b/src/mongo/bson/util/bson_extract.cpp index 84c9cc92de6..8a453c02472 100644 --- a/src/mongo/bson/util/bson_extract.cpp +++ b/src/mongo/bson/util/bson_extract.cpp @@ -185,6 +185,18 @@ Status bsonExtractDoubleField(const BSONObj& object, StringData fieldName, doubl return Status::OK(); } +Status bsonExtractDoubleFieldWithDefault(const BSONObj& object, + StringData fieldName, + double defaultValue, + double* out) { + Status status = bsonExtractDoubleField(object, fieldName, out); + if (status == ErrorCodes::NoSuchKey) { + *out = defaultValue; + status = Status::OK(); + } + return status; +} + Status bsonExtractIntegerFieldWithDefault(const BSONObj& object, StringData fieldName, long long defaultValue, |