diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-05-16 14:48:19 -0400 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-05-21 16:35:25 -0400 |
commit | f30e70b5d1ebae87f373de108314993e58309739 (patch) | |
tree | 97b5f921d9329cd573fc76d536105c50196d04d2 /src/mongo/executor | |
parent | db55694f289d99db4f808a44643130818f3048a4 (diff) | |
download | mongo-f30e70b5d1ebae87f373de108314993e58309739.tar.gz |
SERVER-36099 Trim FTDC connection pool stats
Diffstat (limited to 'src/mongo/executor')
-rw-r--r-- | src/mongo/executor/connection_pool_stats.cpp | 25 | ||||
-rw-r--r-- | src/mongo/executor/connection_pool_stats.h | 2 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/mongo/executor/connection_pool_stats.cpp b/src/mongo/executor/connection_pool_stats.cpp index d2f0fbfa8cb..b1d558bfd8b 100644 --- a/src/mongo/executor/connection_pool_stats.cpp +++ b/src/mongo/executor/connection_pool_stats.cpp @@ -69,24 +69,39 @@ void ConnectionPoolStats::updateStatsForHost(std::string pool, totalRefreshing += newStats.refreshing; } -void ConnectionPoolStats::appendToBSON(mongo::BSONObjBuilder& result) { +void ConnectionPoolStats::appendToBSON(mongo::BSONObjBuilder& result, bool forFTDC) { result.appendNumber("totalInUse", totalInUse); result.appendNumber("totalAvailable", totalAvailable); result.appendNumber("totalCreated", totalCreated); result.appendNumber("totalRefreshing", totalRefreshing); + if (forFTDC) { + BSONObjBuilder poolBuilder(result.subobjStart("connectionsInUsePerPool")); + for (const auto& pool : statsByPool) { + BSONObjBuilder poolInfo(poolBuilder.subobjStart(pool.first)); + auto& poolStats = pool.second; + poolInfo.appendNumber("poolInUse", poolStats.inUse); + for (const auto& host : statsByPoolHost[pool.first]) { + auto hostStats = host.second; + poolInfo.appendNumber(host.first.toString(), hostStats.inUse); + } + } + + return; + } + { BSONObjBuilder poolBuilder(result.subobjStart("pools")); - for (auto&& pool : statsByPool) { + for (const auto& pool : statsByPool) { BSONObjBuilder poolInfo(poolBuilder.subobjStart(pool.first)); - auto poolStats = pool.second; + auto& poolStats = pool.second; poolInfo.appendNumber("poolInUse", poolStats.inUse); poolInfo.appendNumber("poolAvailable", poolStats.available); poolInfo.appendNumber("poolCreated", poolStats.created); poolInfo.appendNumber("poolRefreshing", poolStats.refreshing); - for (auto&& host : statsByPoolHost[pool.first]) { + for (const auto& host : statsByPoolHost[pool.first]) { BSONObjBuilder hostInfo(poolInfo.subobjStart(host.first.toString())); - auto hostStats = host.second; + auto& hostStats = host.second; hostInfo.appendNumber("inUse", hostStats.inUse); hostInfo.appendNumber("available", hostStats.available); hostInfo.appendNumber("created", hostStats.created); diff --git a/src/mongo/executor/connection_pool_stats.h b/src/mongo/executor/connection_pool_stats.h index 374ba60aa62..0e5ec17407a 100644 --- a/src/mongo/executor/connection_pool_stats.h +++ b/src/mongo/executor/connection_pool_stats.h @@ -60,7 +60,7 @@ struct ConnectionStatsPer { struct ConnectionPoolStats { void updateStatsForHost(std::string pool, HostAndPort host, ConnectionStatsPer newStats); - void appendToBSON(mongo::BSONObjBuilder& result); + void appendToBSON(mongo::BSONObjBuilder& result, bool forFTDC = false); size_t totalInUse = 0u; size_t totalAvailable = 0u; |