diff options
author | James Wahlin <james@mongodb.com> | 2020-12-14 18:24:45 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-15 13:17:38 +0000 |
commit | 1741806fb46c161a1d42870f6e98f5100d196315 (patch) | |
tree | 0da2d3663172293d97e589ef3da013a5fe7a234d /src | |
parent | f7a2ba817a319de80932aeb50d92908f58ec8510 (diff) | |
download | mongo-1741806fb46c161a1d42870f6e98f5100d196315.tar.gz |
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/commands/profile_common.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/mongo/db/commands/profile_common.cpp b/src/mongo/db/commands/profile_common.cpp index c3ed936d753..d29ddf948e5 100644 --- a/src/mongo/db/commands/profile_common.cpp +++ b/src/mongo/db/commands/profile_common.cpp @@ -27,13 +27,16 @@ * exception statement from all source files in the program, then also delete * it in the license file. */ +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kCommand #include "mongo/platform/basic.h" #include "mongo/db/auth/authorization_session.h" #include "mongo/db/commands/profile_common.h" #include "mongo/db/commands/profile_gen.h" +#include "mongo/db/jsobj.h" #include "mongo/idl/idl_parser.h" +#include "mongo/util/log.h" namespace mongo { @@ -70,10 +73,12 @@ bool ProfileCmdBase::run(OperationContext* opCtx, // Delegate to _applyProfilingLevel to set the profiling level appropriately whether we are on // mongoD or mongoS. int oldLevel = _applyProfilingLevel(opCtx, dbName, profilingLevel); + auto oldSlowMS = serverGlobalParams.slowMS; + auto oldSampleRate = serverGlobalParams.sampleRate; result.append("was", oldLevel); - result.append("slowms", serverGlobalParams.slowMS); - result.append("sampleRate", serverGlobalParams.sampleRate); + result.append("slowms", oldSlowMS); + result.append("sampleRate", oldSampleRate); if (auto slowms = request.getSlowms()) { serverGlobalParams.slowMS = *slowms; @@ -85,6 +90,24 @@ bool ProfileCmdBase::run(OperationContext* opCtx, serverGlobalParams.sampleRate = *sampleRate; } + // Log the change made to server's profiling settings, unless the request was to get the current + // value. + if (profilingLevel != -1) { + BSONObjBuilder oldState; + BSONObjBuilder newState; + + oldState.append("level"_sd, oldLevel); + oldState.append("slowms"_sd, oldSlowMS); + oldState.append("sampleRate"_sd, oldSampleRate); + + newState.append("level"_sd, profilingLevel); + newState.append("slowms"_sd, serverGlobalParams.slowMS); + newState.append("sampleRate"_sd, serverGlobalParams.sampleRate); + + LOG(0) << "{msg: \"Profiler settings changed\", from:" << oldState.obj() + << ", to:" << newState.obj() << "}"; + } + return true; } } // namespace mongo |