diff options
author | Pol Pinol Castuera <pol.pinol@mongodb.com> | 2022-11-29 07:56:52 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-11-29 08:28:01 +0000 |
commit | 923b5fd65ad075c7da30af55022df936f4339128 (patch) | |
tree | 9087851bfd03cb46641c18709c929403910acd04 /src/mongo/db | |
parent | b6ff8ad7ad404430b05353fb6a2f8b1c01005ea3 (diff) | |
download | mongo-923b5fd65ad075c7da30af55022df936f4339128.tar.gz |
SERVER-68576 Added number of sharded collections to serverStatus command.
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/s/sharding_server_status.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/db/s/sharding_server_status.cpp b/src/mongo/db/s/sharding_server_status.cpp index c47bfd6388e..8369f3cbc5f 100644 --- a/src/mongo/db/s/sharding_server_status.cpp +++ b/src/mongo/db/s/sharding_server_status.cpp @@ -31,6 +31,7 @@ #include "mongo/bson/bsonobjbuilder.h" #include "mongo/db/commands/server_status.h" +#include "mongo/db/db_raii.h" #include "mongo/db/s/active_migrations_registry.h" #include "mongo/db/s/collection_sharding_state.h" #include "mongo/db/s/range_deleter_service.h" @@ -134,6 +135,16 @@ public: CollectionShardingState::appendInfoForServerStatus(opCtx, &result); } + // To calculate the number of sharded collection we simply get the number of records from + // `config.collections` collection. This count must only be appended when serverStatus is + // invoked on the config server. + if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) { + AutoGetCollectionForRead autoColl(opCtx, CollectionType::ConfigNS); + const auto& collection = autoColl.getCollection(); + const auto numShardedCollections = collection ? collection->numRecords(opCtx) : 0; + result.append("numShardedCollections", numShardedCollections); + } + reportDataTransformMetrics(opCtx, &result); return result.obj(); |