void ConnectionPoolStats::appendToBSON(mongo::BSONObjBuilder& result) {
    result.appendNumber("totalInUse", totalInUse);
    result.appendNumber("totalAvailable", totalAvailable);
    result.appendNumber("totalCreated", totalCreated);

    BSONObjBuilder hostBuilder(result.subobjStart("hosts"));
    for (auto&& host : statsByHost) {
        BSONObjBuilder hostInfo(hostBuilder.subobjStart(host.first.toString()));

        auto hostStats = host.second;
        hostInfo.appendNumber("inUse", hostStats.inUse);
        hostInfo.appendNumber("available", hostStats.available);
        hostInfo.appendNumber("created", hostStats.created);
    }
}
Example #2
0
void ConnectionPoolStats::appendToBSON(mongo::BSONObjBuilder& result) {
    result.appendNumber("totalInUse", totalInUse);
    result.appendNumber("totalAvailable", totalAvailable);
    result.appendNumber("totalCreated", totalCreated);
    result.appendNumber("totalRefreshing", totalRefreshing);

    {
        BSONObjBuilder poolBuilder(result.subobjStart("pools"));
        for (auto&& pool : statsByPool) {
            BSONObjBuilder poolInfo(poolBuilder.subobjStart(pool.first));
            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]) {
                BSONObjBuilder hostInfo(poolInfo.subobjStart(host.first.toString()));
                auto hostStats = host.second;
                hostInfo.appendNumber("inUse", hostStats.inUse);
                hostInfo.appendNumber("available", hostStats.available);
                hostInfo.appendNumber("created", hostStats.created);
                hostInfo.appendNumber("refreshing", hostStats.refreshing);
            }
        }
    }
    {
        BSONObjBuilder hostBuilder(result.subobjStart("hosts"));
        for (auto&& host : statsByHost) {
            BSONObjBuilder hostInfo(hostBuilder.subobjStart(host.first.toString()));
            auto hostStats = host.second;
            hostInfo.appendNumber("inUse", hostStats.inUse);
            hostInfo.appendNumber("available", hostStats.available);
            hostInfo.appendNumber("created", hostStats.created);
            hostInfo.appendNumber("refreshing", hostStats.refreshing);
        }
    }
}