diff options
author | Maddie Zechar <maddie.zechar@mongodb.com> | 2023-05-11 14:41:01 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-11 15:59:23 +0000 |
commit | 2f667bface2924113e5812be0972874bb95e6436 (patch) | |
tree | eb4aab8b07f4840d0ffa81aa6d3134bff15dc087 /src/mongo/db/query/query_shape.cpp | |
parent | dcd8c050fb807cd6a30f1c3f833f4be23c22fdcf (diff) | |
download | mongo-2f667bface2924113e5812be0972874bb95e6436.tar.gz |
SERVER-76143 Add missing find command fields to queryStats key
Diffstat (limited to 'src/mongo/db/query/query_shape.cpp')
-rw-r--r-- | src/mongo/db/query/query_shape.cpp | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/src/mongo/db/query/query_shape.cpp b/src/mongo/db/query/query_shape.cpp index 817583304a0..519b1115558 100644 --- a/src/mongo/db/query/query_shape.cpp +++ b/src/mongo/db/query/query_shape.cpp @@ -100,10 +100,9 @@ BSONObj extractSortShape(const BSONObj& sortSpec, } static std::string hintSpecialField = "$hint"; -void addLiteralFields(BSONObjBuilder* bob, +void addShapeLiterals(BSONObjBuilder* bob, const FindCommandRequest& findCommand, const SerializationOptions& opts) { - if (auto limit = findCommand.getLimit()) { opts.appendLiteral( bob, FindCommandRequest::kLimitFieldName, static_cast<long long>(*limit)); @@ -111,17 +110,6 @@ void addLiteralFields(BSONObjBuilder* bob, if (auto skip = findCommand.getSkip()) { opts.appendLiteral(bob, FindCommandRequest::kSkipFieldName, static_cast<long long>(*skip)); } - if (auto batchSize = findCommand.getBatchSize()) { - opts.appendLiteral( - bob, FindCommandRequest::kBatchSizeFieldName, static_cast<long long>(*batchSize)); - } - if (auto maxTimeMs = findCommand.getMaxTimeMS()) { - opts.appendLiteral(bob, FindCommandRequest::kMaxTimeMSFieldName, *maxTimeMs); - } - if (auto noCursorTimeout = findCommand.getNoCursorTimeout()) { - opts.appendLiteral( - bob, FindCommandRequest::kNoCursorTimeoutFieldName, bool(noCursorTimeout)); - } } static std::vector< @@ -133,9 +121,8 @@ static std::vector< {FindCommandRequest::kShowRecordIdFieldName, &FindCommandRequest::getShowRecordId}, {FindCommandRequest::kTailableFieldName, &FindCommandRequest::getTailable}, {FindCommandRequest::kAwaitDataFieldName, &FindCommandRequest::getAwaitData}, - {FindCommandRequest::kAllowPartialResultsFieldName, - &FindCommandRequest::getAllowPartialResults}, {FindCommandRequest::kMirroredFieldName, &FindCommandRequest::getMirrored}, + {FindCommandRequest::kOplogReplayFieldName, &FindCommandRequest::getOplogReplay}, }; std::vector<std::pair<StringData, std::function<const BSONObj(const FindCommandRequest&)>>> objArgMap = { @@ -230,19 +217,7 @@ BSONObj extractQueryShape(const FindCommandRequest& findCommand, } } - // Redact the namespace of the command. - { - auto nssOrUUID = findCommand.getNamespaceOrUUID(); - std::string toSerialize; - if (nssOrUUID.uuid()) { - toSerialize = opts.serializeIdentifier(nssOrUUID.toString()); - } else { - // Database is set at the command level, only serialize the collection here. - toSerialize = opts.serializeIdentifier(nssOrUUID.nss()->coll()); - } - bob.append(FindCommandRequest::kCommandName, toSerialize); - } - + bob.append("command", "find"); std::unique_ptr<MatchExpression> filterExpr; // Filter. { @@ -299,8 +274,8 @@ BSONObj extractQueryShape(const FindCommandRequest& findCommand, query_shape::extractSortShape(findCommand.getSort(), expCtx, opts)); } - // Fields for literal redaction. Adds limit, skip, batchSize, maxTimeMS, and noCursorTimeOut - addLiteralFields(&bob, findCommand, opts); + // Fields for literal redaction. Adds limit and skip. + addShapeLiterals(&bob, findCommand, opts); // Add the fields that require no redaction. addRemainingFindCommandFields(&bob, findCommand, opts); |