diff options
author | Varun Ravichandran <varun.ravichandran@mongodb.com> | 2021-04-01 03:31:12 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-04-30 21:06:36 +0000 |
commit | c1213e2bbfb379d3defdc08a48067a350e84027c (patch) | |
tree | 96dd8a62b4924c11cdbfefc8227b9301e35c4cf6 /src/mongo/db/curop.cpp | |
parent | 272b9e0bd2425ae15766b198de0f6a1a522bf8d3 (diff) | |
download | mongo-c1213e2bbfb379d3defdc08a48067a350e84027c.tar.gz |
SERVER-46412: Track, log, and profile user cache acquisition stats in CurOp
Diffstat (limited to 'src/mongo/db/curop.cpp')
-rw-r--r-- | src/mongo/db/curop.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index 6a2e0aead94..29e63a3a1e9 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -936,6 +936,14 @@ string OpDebug::report(OperationContext* opCtx, const SingleThreadedLockStats* l s << " locks:" << locks.obj().toString(); } + auto userCacheAcquisitionStats = curop.getReadOnlyUserCacheAcquisitionStats(); + if (userCacheAcquisitionStats->shouldReport()) { + StringBuilder userCacheAcquisitionStatsBuilder; + userCacheAcquisitionStats->toString(&userCacheAcquisitionStatsBuilder, + opCtx->getServiceContext()->getTickSource()); + s << " authorization:" << userCacheAcquisitionStatsBuilder.str(); + } + BSONObj flowControlObj = makeFlowControlObject(flowControlStats); if (flowControlObj.nFields() > 0) { s << " flowControl:" << flowControlObj.toString(); @@ -1107,6 +1115,14 @@ void OpDebug::report(OperationContext* opCtx, pAttrs->add("locks", locks.obj()); } + auto userCacheAcquisitionStats = curop.getReadOnlyUserCacheAcquisitionStats(); + if (userCacheAcquisitionStats->shouldReport()) { + BSONObjBuilder userCacheAcquisitionStatsBuilder; + userCacheAcquisitionStats->report(&userCacheAcquisitionStatsBuilder, + opCtx->getServiceContext()->getTickSource()); + pAttrs->add("authorization", userCacheAcquisitionStatsBuilder.obj()); + } + BSONObj flowControlObj = makeFlowControlObject(flowControlStats); if (flowControlObj.nFields() > 0) { pAttrs->add("flowControl", flowControlObj); @@ -1231,6 +1247,15 @@ void OpDebug::append(OperationContext* opCtx, } { + auto userCacheAcquisitionStats = curop.getReadOnlyUserCacheAcquisitionStats(); + if (userCacheAcquisitionStats->shouldReport()) { + BSONObjBuilder userCacheAcquisitionStatsBuilder(b.subobjStart("authorization")); + userCacheAcquisitionStats->report(&userCacheAcquisitionStatsBuilder, + opCtx->getServiceContext()->getTickSource()); + } + } + + { BSONObj flowControlMetrics = makeFlowControlObject(flowControlStats); BSONObjBuilder flowControlBuilder(b.subobjStart("flowControl")); flowControlBuilder.appendElements(flowControlMetrics); @@ -1488,6 +1513,15 @@ std::function<BSONObj(ProfileFilter::Args)> OpDebug::appendStaged(StringSet requ } }); + addIfNeeded("authorization", [](auto field, auto args, auto& b) { + auto userCacheAcquisitionStats = args.curop.getReadOnlyUserCacheAcquisitionStats(); + if (userCacheAcquisitionStats->shouldReport()) { + BSONObjBuilder userCacheAcquisitionStatsBuilder(b.subobjStart(field)); + userCacheAcquisitionStats->report(&userCacheAcquisitionStatsBuilder, + args.opCtx->getServiceContext()->getTickSource()); + } + }); + addIfNeeded("flowControl", [](auto field, auto args, auto& b) { BSONObj flowControlMetrics = makeFlowControlObject(args.opCtx->lockState()->getFlowControlStats()); |