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.h | |
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.h')
-rw-r--r-- | src/mongo/db/curop.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 84feaace21c..44530fcfbfd 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -32,6 +32,7 @@ #include "mongo/config.h" #include "mongo/db/auth/authorization_session.h" +#include "mongo/db/auth/user_cache_acquisition_stats.h" #include "mongo/db/catalog/collection_catalog.h" #include "mongo/db/clientcursor.h" #include "mongo/db/commands.h" @@ -420,6 +421,25 @@ public: } /** + * Returns a const pointer to the authorization user cache statistics for the current operation. + * This can only be used for reading (i.e., when logging or profiling). + */ + const UserCacheAcquisitionStats* getReadOnlyUserCacheAcquisitionStats() const { + return &_userCacheAcquisitionStats; + } + + /** + * Returns an instance of UserCacheAcquisitionStatsHandle. By doing so, it automatically records + * the start of the user cache access attempt upon creation. If the cache access is not + * completed and recorded normally before it is about to be destroyed (i.e., due to an + * exception), it will be automatically recorded as complete then. + */ + UserCacheAcquisitionStatsHandle getMutableUserCacheAcquisitionStats(Client* client, + TickSource* tickSource) { + return UserCacheAcquisitionStatsHandle(&_userCacheAcquisitionStats, client, tickSource); + } + + /** * Gets the name of the namespace on which the current operation operates. */ NamespaceString getNSS() const { @@ -815,6 +835,8 @@ private: boost::optional<SingleThreadedLockStats> _lockStatsBase; // This is the snapshot of lock stats taken when curOp is constructed. + UserCacheAcquisitionStats _userCacheAcquisitionStats; + TickSource* _tickSource = nullptr; }; |