summaryrefslogtreecommitdiff
path: root/src/mongo/db/db_raii.cpp
diff options
context:
space:
mode:
authorMihai Andrei <mihai.andrei@10gen.com>2022-01-31 18:06:17 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-31 18:37:17 +0000
commitf5dbab9f268eae5471fdbf2c2660fdec240f80ec (patch)
tree9fb21ca8936008f7b16f9d667d396f46480e6270 /src/mongo/db/db_raii.cpp
parent539ce23761785a90ac28da2ab40203ea0fdf59b1 (diff)
downloadmongo-f5dbab9f268eae5471fdbf2c2660fdec240f80ec.tar.gz
SERVER-62674 Add stats tracking for multiple collections
Diffstat (limited to 'src/mongo/db/db_raii.cpp')
-rw-r--r--src/mongo/db/db_raii.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp
index 86099c1b145..aaab7666d87 100644
--- a/src/mongo/db/db_raii.cpp
+++ b/src/mongo/db/db_raii.cpp
@@ -238,14 +238,21 @@ AutoStatsTracker::AutoStatsTracker(OperationContext* opCtx,
Top::LockType lockType,
LogMode logMode,
int dbProfilingLevel,
- Date_t deadline)
- : _opCtx(opCtx), _lockType(lockType), _nss(nss), _logMode(logMode) {
+ Date_t deadline,
+ const std::vector<NamespaceString>& secondaryNssVector)
+ : _opCtx(opCtx), _lockType(lockType), _logMode(logMode) {
+ // Deduplicate all namespaces for Top reporting on destruct.
+ _nssSet.insert(nss);
+ for (auto&& secondaryNss : secondaryNssVector) {
+ _nssSet.insert(secondaryNss);
+ }
+
if (_logMode == LogMode::kUpdateTop) {
return;
}
stdx::lock_guard<Client> clientLock(*_opCtx->getClient());
- CurOp::get(_opCtx)->enter_inlock(_nss.ns().c_str(), dbProfilingLevel);
+ CurOp::get(_opCtx)->enter_inlock(nss.ns().c_str(), dbProfilingLevel);
}
AutoStatsTracker::~AutoStatsTracker() {
@@ -253,10 +260,11 @@ AutoStatsTracker::~AutoStatsTracker() {
return;
}
+ // Update stats for each namespace.
auto curOp = CurOp::get(_opCtx);
Top::get(_opCtx->getServiceContext())
.record(_opCtx,
- _nss.ns(),
+ _nssSet,
curOp->getLogicalOp(),
_lockType,
durationCount<Microseconds>(curOp->elapsedTimeExcludingPauses()),