summaryrefslogtreecommitdiff
path: root/src/mongo/db/client.cpp
diff options
context:
space:
mode:
authorAmirsaman Memaripour <amirsaman.memaripour@mongodb.com>2020-10-02 02:40:31 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-14 15:29:48 +0000
commit1f0009a389042c24360509625d50a9e3812658c7 (patch)
treedfd754ceb4fa7c0a92ddd919e9759f9fe307528c /src/mongo/db/client.cpp
parent687a70903fc5f10de9066ac92e1b9e0806924327 (diff)
downloadmongo-1f0009a389042c24360509625d50a9e3812658c7.tar.gz
SERVER-47446 Measure cpu time taken by operations
Diffstat (limited to 'src/mongo/db/client.cpp')
-rw-r--r--src/mongo/db/client.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp
index a9678bee962..53fdaf2052c 100644
--- a/src/mongo/db/client.cpp
+++ b/src/mongo/db/client.cpp
@@ -42,6 +42,7 @@
#include "mongo/base/status.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/operation_context.h"
+#include "mongo/db/operation_cpu_timer.h"
#include "mongo/db/service_context.h"
#include "mongo/stdx/thread.h"
#include "mongo/util/concurrency/thread_name.h"
@@ -156,12 +157,18 @@ bool haveClient() {
ServiceContext::UniqueClient Client::releaseCurrent() {
invariant(haveClient());
+ if (auto opCtx = currentClient->_opCtx)
+ if (auto timer = OperationCPUTimer::get(opCtx))
+ timer->onThreadDetach();
return std::move(currentClient);
}
void Client::setCurrent(ServiceContext::UniqueClient client) {
invariantNoCurrentClient();
currentClient = std::move(client);
+ if (auto opCtx = currentClient->_opCtx)
+ if (auto timer = OperationCPUTimer::get(opCtx))
+ timer->onThreadAttach();
}
/**