diff options
-rw-r--r-- | jstests/core/profile_agg.js | 1 | ||||
-rw-r--r-- | jstests/core/profile_count.js | 3 | ||||
-rw-r--r-- | jstests/core/profile_delete.js | 3 | ||||
-rw-r--r-- | jstests/core/profile_distinct.js | 2 | ||||
-rw-r--r-- | jstests/core/profile_find.js | 4 | ||||
-rw-r--r-- | jstests/core/profile_findandmodify.js | 6 | ||||
-rw-r--r-- | jstests/core/profile_geonear.js | 1 | ||||
-rw-r--r-- | jstests/core/profile_getmore.js | 3 | ||||
-rw-r--r-- | jstests/core/profile_group.js | 2 | ||||
-rw-r--r-- | jstests/core/profile_insert.js | 6 | ||||
-rw-r--r-- | jstests/core/profile_mapreduce.js | 3 | ||||
-rw-r--r-- | jstests/core/profile_update.js | 5 | ||||
-rw-r--r-- | src/mongo/db/introspect.cpp | 11 |
13 files changed, 49 insertions, 1 deletions
diff --git a/jstests/core/profile_agg.js b/jstests/core/profile_agg.js index ede6f20f85d..51043a2690c 100644 --- a/jstests/core/profile_agg.js +++ b/jstests/core/profile_agg.js @@ -39,6 +39,7 @@ assert(profileObj.hasOwnProperty("numYield"), tojson(profileObj)); assert(profileObj.hasOwnProperty("locks"), tojson(profileObj)); assert(!profileObj.hasOwnProperty("hasSortStage"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm hasSortStage with in-memory sort. diff --git a/jstests/core/profile_count.js b/jstests/core/profile_count.js index 0b04dca01ea..5e448201811 100644 --- a/jstests/core/profile_count.js +++ b/jstests/core/profile_count.js @@ -36,6 +36,7 @@ assert(profileObj.hasOwnProperty("millis"), tojson(profileObj)); assert(profileObj.hasOwnProperty("numYield"), tojson(profileObj)); assert(profileObj.hasOwnProperty("locks"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Count with non-indexed query. @@ -69,6 +70,7 @@ assert.eq(profileObj.keysExamined, 6, tojson(profileObj)); assert.eq(profileObj.planSummary, "COUNT_SCAN { a: 1.0 }", tojson(profileObj)); assert(profileObj.execStats.hasOwnProperty("stage"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm "fromMultiPlanner" metric. @@ -84,4 +86,5 @@ profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.fromMultiPlanner, true, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); })(); diff --git a/jstests/core/profile_delete.js b/jstests/core/profile_delete.js index 5ff39cb026e..937c6327e45 100644 --- a/jstests/core/profile_delete.js +++ b/jstests/core/profile_delete.js @@ -42,6 +42,7 @@ assert(profileObj.hasOwnProperty("millis"), tojson(profileObj)); assert(profileObj.hasOwnProperty("numYield"), tojson(profileObj)); assert(profileObj.hasOwnProperty("locks"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm metrics for multiple document delete. @@ -56,6 +57,7 @@ assert.eq(profileObj.ndeleted, 8, tojson(profileObj)); assert.eq(profileObj.keysDeleted, 8, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm "fromMultiPlanner" metric. @@ -71,4 +73,5 @@ profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.fromMultiPlanner, true, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); })(); diff --git a/jstests/core/profile_distinct.js b/jstests/core/profile_distinct.js index 878c681df0a..aea24f14333 100644 --- a/jstests/core/profile_distinct.js +++ b/jstests/core/profile_distinct.js @@ -38,6 +38,7 @@ assert(profileObj.hasOwnProperty("millis"), tojson(profileObj)); assert(profileObj.hasOwnProperty("numYield"), tojson(profileObj)); assert(profileObj.hasOwnProperty("locks"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm "fromMultiPlanner" metric. @@ -53,4 +54,5 @@ profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.fromMultiPlanner, true, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); })(); diff --git a/jstests/core/profile_find.js b/jstests/core/profile_find.js index af042f44378..43f99e97019 100644 --- a/jstests/core/profile_find.js +++ b/jstests/core/profile_find.js @@ -59,6 +59,7 @@ assert(profileObj.locks.hasOwnProperty("Global"), tojson(profileObj)); assert(profileObj.locks.hasOwnProperty("Database"), tojson(profileObj)); assert(profileObj.locks.hasOwnProperty("Collection"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm "cursorId" and "hasSortStage" metrics. @@ -77,6 +78,7 @@ assert.eq(profileObj.hasSortStage, true, tojson(profileObj)); assert(profileObj.hasOwnProperty("cursorid"), tojson(profileObj)); assert(!profileObj.hasOwnProperty("cursorExhausted"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm "fromMultiPlanner" metric. @@ -92,6 +94,7 @@ profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.fromMultiPlanner, true, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm "replanned" metric. @@ -111,6 +114,7 @@ profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.replanned, true, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm that query modifiers such as "hint" are in the profiler document. diff --git a/jstests/core/profile_findandmodify.js b/jstests/core/profile_findandmodify.js index 1a51bd527ec..6d12e8b98e8 100644 --- a/jstests/core/profile_findandmodify.js +++ b/jstests/core/profile_findandmodify.js @@ -42,6 +42,7 @@ assert(profileObj.execStats.hasOwnProperty("stage"), tojson(profileObj)); assert(profileObj.hasOwnProperty("numYield"), tojson(profileObj)); assert(profileObj.hasOwnProperty("responseLength"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Delete as findAndModify. @@ -64,6 +65,7 @@ assert.eq(profileObj.keysDeleted, 1, tojson(profileObj)); assert.eq(profileObj.planSummary, "COLLSCAN", tojson(profileObj)); assert(profileObj.execStats.hasOwnProperty("stage"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Update with {upsert: true} as findAndModify. @@ -90,6 +92,7 @@ assert.eq(profileObj.nModified, 0, tojson(profileObj)); assert.eq(profileObj.upsert, true, tojson(profileObj)); assert.eq(profileObj.keysInserted, 1, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Idhack update as findAndModify. @@ -106,6 +109,7 @@ assert.eq(profileObj.nMatched, 1, tojson(profileObj)); assert.eq(profileObj.nModified, 1, tojson(profileObj)); assert.eq(profileObj.planSummary, "IDHACK", tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Update as findAndModify with projection. @@ -128,6 +132,7 @@ assert.eq(profileObj.docsExamined, 3, tojson(profileObj)); assert.eq(profileObj.nMatched, 1, tojson(profileObj)); assert.eq(profileObj.nModified, 1, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Delete as findAndModify with projection. @@ -146,6 +151,7 @@ assert.eq(profileObj.command.fields, {_id: 0, a: 1}, tojson(profileObj)); assert(!profileObj.hasOwnProperty("updateobj"), tojson(profileObj)); assert.eq(profileObj.ndeleted, 1, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm "hasSortStage" on findAndModify with sort. diff --git a/jstests/core/profile_geonear.js b/jstests/core/profile_geonear.js index dd348e4c645..d6ec98011f0 100644 --- a/jstests/core/profile_geonear.js +++ b/jstests/core/profile_geonear.js @@ -45,6 +45,7 @@ assert(profileObj.hasOwnProperty("millis"), tojson(profileObj)); assert(profileObj.hasOwnProperty("numYield"), tojson(profileObj)); assert(profileObj.hasOwnProperty("locks"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // We cannot confirm "fromMultiPlanner" or "replanned" metrics as there can be at most one // valid index choice for geoNear. The reason for this is: diff --git a/jstests/core/profile_getmore.js b/jstests/core/profile_getmore.js index 3337de03e73..f9e606fa748 100644 --- a/jstests/core/profile_getmore.js +++ b/jstests/core/profile_getmore.js @@ -52,6 +52,7 @@ assert(profileObj.locks.hasOwnProperty("Collection"), tojson(profileObj)); assert(profileObj.hasOwnProperty("millis"), tojson(profileObj)); assert(!profileObj.hasOwnProperty("cursorExhausted"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm hasSortStage on getMore with a not-exhausted cursor and in-memory sort. @@ -88,6 +89,7 @@ tojson(profileObj)); // cursorid should always be present on getMore. assert.neq(0, profileObj.cursorid, tojson(profileObj)); assert.eq(profileObj.cursorExhausted, true, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm getMore on aggregation. @@ -119,4 +121,5 @@ assert.eq(profileObj.cursorExhausted, true, tojson(profileObj)); assert.eq(profileObj.keysExamined, 20, tojson(profileObj)); assert.eq(profileObj.docsExamined, 20, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); })(); diff --git a/jstests/core/profile_group.js b/jstests/core/profile_group.js index dcbf4c8611f..f1a2e3b48b3 100644 --- a/jstests/core/profile_group.js +++ b/jstests/core/profile_group.js @@ -45,6 +45,7 @@ assert(profileObj.hasOwnProperty("millis"), tojson(profileObj)); assert(profileObj.hasOwnProperty("numYield"), tojson(profileObj)); assert(profileObj.hasOwnProperty("locks"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm "fromMultiPlanner" metric. @@ -60,4 +61,5 @@ profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.fromMultiPlanner, true, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); })(); diff --git a/jstests/core/profile_insert.js b/jstests/core/profile_insert.js index e49699a9d11..bd741a9a8d5 100644 --- a/jstests/core/profile_insert.js +++ b/jstests/core/profile_insert.js @@ -43,6 +43,7 @@ assert(profileObj.hasOwnProperty("millis"), tojson(profileObj)); assert(profileObj.hasOwnProperty("ts"), tojson(profileObj)); assert(profileObj.hasOwnProperty("client"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Test multi-insert. @@ -64,10 +65,12 @@ assert.eq(profileObj.ninserted, 2, tojson(profileObj)); assert.eq(profileObj.keysInserted, 2, tojson(profileObj)); assert.eq(profileObj.query.documents, docArray, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); } else { // Documents were inserted one at a time. assert.eq(profileObj.ninserted, 1, tojson(profileObj)); assert.eq(profileObj.keysInserted, 1, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); } // @@ -84,5 +87,6 @@ assert.eq(profileObj.query.ordered, false, tojson(profileObj)); assert.eq(profileObj.query.writeConcern.w, 1, tojson(profileObj)); assert.eq(profileObj.query.writeConcern.wtimeout, wtimeout, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); } -})();
\ No newline at end of file +})(); diff --git a/jstests/core/profile_mapreduce.js b/jstests/core/profile_mapreduce.js index 20e3b2e8fbf..181e8684501 100644 --- a/jstests/core/profile_mapreduce.js +++ b/jstests/core/profile_mapreduce.js @@ -49,6 +49,7 @@ assert(profileObj.hasOwnProperty("millis"), tojson(profileObj)); assert(profileObj.hasOwnProperty("numYield"), tojson(profileObj)); assert(profileObj.hasOwnProperty("locks"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm metrics for mapReduce with sort stage. @@ -62,6 +63,7 @@ profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.hasSortStage, true, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm namespace field is correct when output is a collection. @@ -91,4 +93,5 @@ profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.fromMultiPlanner, true, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); })(); diff --git a/jstests/core/profile_update.js b/jstests/core/profile_update.js index 1132e63a57f..41727b89580 100644 --- a/jstests/core/profile_update.js +++ b/jstests/core/profile_update.js @@ -44,6 +44,7 @@ assert(profileObj.hasOwnProperty("millis"), tojson(profileObj)); assert(profileObj.hasOwnProperty("numYield"), tojson(profileObj)); assert(profileObj.hasOwnProperty("locks"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm metrics for multiple indexed document update. @@ -65,6 +66,7 @@ assert.eq(profileObj.nModified, 5, tojson(profileObj)); assert.eq(profileObj.planSummary, "IXSCAN { a: 1.0 }", tojson(profileObj)); assert(profileObj.execStats.hasOwnProperty("stage"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm metrics for insert on update with "upsert: true". @@ -88,6 +90,7 @@ assert.eq(profileObj.upsert, true, tojson(profileObj)); assert.eq(profileObj.planSummary, "IXSCAN { _id: 1 }", tojson(profileObj)); assert(profileObj.execStats.hasOwnProperty("stage"), tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); // // Confirm 'nmoved' for MMAPv1. @@ -104,6 +107,7 @@ assert.eq(profileObj.nMatched, 1, tojson(profileObj)); assert.eq(profileObj.nModified, 1, tojson(profileObj)); assert.eq(profileObj.nmoved, 1, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); } // @@ -120,4 +124,5 @@ profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.fromMultiPlanner, true, tojson(profileObj)); + assert.eq(profileObj.appName, "MongoDB Shell", tojson(profileObj)); })(); diff --git a/src/mongo/db/introspect.cpp b/src/mongo/db/introspect.cpp index 55ae0dba84d..3bc23d3fa93 100644 --- a/src/mongo/db/introspect.cpp +++ b/src/mongo/db/introspect.cpp @@ -41,6 +41,8 @@ #include "mongo/db/curop.h" #include "mongo/db/db_raii.h" #include "mongo/db/jsobj.h" +#include "mongo/rpc/metadata/client_metadata.h" +#include "mongo/rpc/metadata/client_metadata_ismaster.h" #include "mongo/util/log.h" #include "mongo/util/scopeguard.h" @@ -95,6 +97,15 @@ void profile(OperationContext* txn, NetworkOp op) { b.appendDate("ts", jsTime()); b.append("client", txn->getClient()->clientAddress()); + const auto& clientMetadata = + ClientMetadataIsMasterState::get(txn->getClient()).getClientMetadata(); + if (clientMetadata) { + auto appName = clientMetadata.get().getApplicationName(); + if (!appName.empty()) { + b.append("appName", appName); + } + } + AuthorizationSession* authSession = AuthorizationSession::get(txn->getClient()); _appendUserInfo(*CurOp::get(txn), b, authSession); |