From c1213e2bbfb379d3defdc08a48067a350e84027c Mon Sep 17 00:00:00 2001 From: Varun Ravichandran Date: Thu, 1 Apr 2021 03:31:12 +0000 Subject: SERVER-46412: Track, log, and profile user cache acquisition stats in CurOp --- src/mongo/db/curop.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/mongo/db/curop.h') 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" @@ -419,6 +420,25 @@ public: return _ns; } + /** + * 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. */ @@ -815,6 +835,8 @@ private: boost::optional _lockStatsBase; // This is the snapshot of lock stats taken when curOp is constructed. + UserCacheAcquisitionStats _userCacheAcquisitionStats; + TickSource* _tickSource = nullptr; }; -- cgit v1.2.1