void OpDebug::append(const CurOp& curop, const SingleThreadedLockStats& lockStats, BSONObjBuilder& b) const { const size_t maxElementSize = 50 * 1024; b.append( "op" , iscommand ? "command" : opToString( op ) ); b.append( "ns" , ns.toString() ); if (!query.isEmpty()) { appendAsObjOrString(iscommand ? "command" : "query", query, maxElementSize, &b); } else if (!iscommand && curop.haveQuery()) { appendAsObjOrString("query", curop.query(), maxElementSize, &b); } if (!updateobj.isEmpty()) { appendAsObjOrString("updateobj", updateobj, maxElementSize, &b); } const bool moved = (nmoved >= 1); OPDEBUG_APPEND_NUMBER( cursorid ); OPDEBUG_APPEND_NUMBER( ntoreturn ); OPDEBUG_APPEND_NUMBER( ntoskip ); OPDEBUG_APPEND_BOOL( exhaust ); OPDEBUG_APPEND_NUMBER( nscanned ); OPDEBUG_APPEND_NUMBER( nscannedObjects ); OPDEBUG_APPEND_BOOL( idhack ); OPDEBUG_APPEND_BOOL( scanAndOrder ); OPDEBUG_APPEND_BOOL( moved ); OPDEBUG_APPEND_NUMBER( nmoved ); OPDEBUG_APPEND_NUMBER( nMatched ); OPDEBUG_APPEND_NUMBER( nModified ); OPDEBUG_APPEND_NUMBER( ninserted ); OPDEBUG_APPEND_NUMBER( ndeleted ); OPDEBUG_APPEND_BOOL( fastmod ); OPDEBUG_APPEND_BOOL( fastmodinsert ); OPDEBUG_APPEND_BOOL( upsert ); OPDEBUG_APPEND_BOOL( cursorExhausted ); OPDEBUG_APPEND_NUMBER( keyUpdates ); OPDEBUG_APPEND_NUMBER( writeConflicts ); b.appendNumber("numYield", curop.numYields()); { BSONObjBuilder locks(b.subobjStart("locks")); lockStats.report(&locks); } if (!exceptionInfo.empty()) { exceptionInfo.append(b, "exception", "exceptionCode"); } OPDEBUG_APPEND_NUMBER( nreturned ); OPDEBUG_APPEND_NUMBER( responseLength ); b.append( "millis" , executionTime ); execStats.append(b, "execStats"); }
void OpDebug::append( const CurOp& curop, BSONObjBuilder& b ) const { b.append( "op" , iscommand ? "command" : opToString( op ) ); b.append( "ns" , ns.toString() ); if ( ! query.isEmpty() ) b.append( iscommand ? "command" : "query" , query ); else if ( ! iscommand && curop.haveQuery() ) curop.appendQuery( b , "query" ); if ( ! updateobj.isEmpty() ) b.append( "updateobj" , updateobj ); OPDEBUG_APPEND_NUMBER( cursorid ); OPDEBUG_APPEND_NUMBER( ntoreturn ); OPDEBUG_APPEND_NUMBER( ntoskip ); OPDEBUG_APPEND_BOOL( exhaust ); OPDEBUG_APPEND_NUMBER( nscanned ); OPDEBUG_APPEND_BOOL( idhack ); OPDEBUG_APPEND_BOOL( scanAndOrder ); OPDEBUG_APPEND_BOOL( moved ); OPDEBUG_APPEND_BOOL( fastmod ); OPDEBUG_APPEND_BOOL( fastmodinsert ); OPDEBUG_APPEND_BOOL( upsert ); OPDEBUG_APPEND_NUMBER( keyUpdates ); if ( ! exceptionInfo.empty() ) exceptionInfo.append( b , "exception" , "exceptionCode" ); OPDEBUG_APPEND_NUMBER( nreturned ); OPDEBUG_APPEND_NUMBER( responseLength ); b.append( "millis" , executionTime ); }
void OpDebug::append(const CurOp& curop, const SingleThreadedLockStats& lockStats, BSONObjBuilder& b) const { const size_t maxElementSize = 50 * 1024; b.append("op", logicalOpToString(logicalOp)); NamespaceString nss = NamespaceString(curop.getNS()); b.append("ns", nss.ns()); if (!iscommand && networkOp == dbQuery) { appendAsObjOrString( "query", upconvertQueryEntry(query, nss, ntoreturn, ntoskip), maxElementSize, &b); } else if (!iscommand && networkOp == dbGetMore) { appendAsObjOrString( "query", upconvertGetMoreEntry(nss, cursorid, ntoreturn), maxElementSize, &b); } else if (!query.isEmpty()) { const char* fieldName = (logicalOp == LogicalOp::opCommand) ? "command" : "query"; appendAsObjOrString(fieldName, query, maxElementSize, &b); } else if (!iscommand && curop.haveQuery()) { appendAsObjOrString("query", curop.query(), maxElementSize, &b); } if (!updateobj.isEmpty()) { appendAsObjOrString("updateobj", updateobj, maxElementSize, &b); } OPDEBUG_APPEND_NUMBER(cursorid); OPDEBUG_APPEND_BOOL(exhaust); OPDEBUG_APPEND_NUMBER(keysExamined); OPDEBUG_APPEND_NUMBER(docsExamined); OPDEBUG_APPEND_BOOL(hasSortStage); OPDEBUG_APPEND_BOOL(fromMultiPlanner); OPDEBUG_APPEND_BOOL(replanned); OPDEBUG_APPEND_NUMBER(nMatched); OPDEBUG_APPEND_NUMBER(nModified); OPDEBUG_APPEND_NUMBER(ninserted); OPDEBUG_APPEND_NUMBER(ndeleted); OPDEBUG_APPEND_BOOL(fastmodinsert); OPDEBUG_APPEND_BOOL(upsert); OPDEBUG_APPEND_BOOL(cursorExhausted); if (nmoved > 0) { b.appendNumber("nmoved", nmoved); } if (keysInserted > 0) { b.appendNumber("keysInserted", keysInserted); } if (keysDeleted > 0) { b.appendNumber("keysDeleted", keysDeleted); } if (writeConflicts > 0) { b.appendNumber("writeConflicts", writeConflicts); } b.appendNumber("numYield", curop.numYields()); { BSONObjBuilder locks(b.subobjStart("locks")); lockStats.report(&locks); } if (!exceptionInfo.empty()) { exceptionInfo.append(b, "exception", "exceptionCode"); } OPDEBUG_APPEND_NUMBER(nreturned); OPDEBUG_APPEND_NUMBER(responseLength); if (iscommand) { b.append("protocol", getProtoString(networkOp)); } b.append("millis", executionTime); if (!curop.getPlanSummary().empty()) { b.append("planSummary", curop.getPlanSummary()); } if (execStats.have()) { execStats.append(b, "execStats"); } }
bool OpDebug::append(const CurOp& curop, BSONObjBuilder& b, size_t maxSize) const { b.append( "op" , iscommand ? "command" : opToString( op ) ); b.append( "ns" , ns.toString() ); int queryUpdateObjSize = 0; if (!query.isEmpty()) { queryUpdateObjSize += query.objsize(); } else if (!iscommand && curop.haveQuery()) { queryUpdateObjSize += curop.query()["query"].size(); } if (!updateobj.isEmpty()) { queryUpdateObjSize += updateobj.objsize(); } if (static_cast<size_t>(queryUpdateObjSize) > maxSize) { if (!query.isEmpty()) { // Use 60 since BSONObj::toString can truncate strings into 150 chars // and we want to have enough room for both query and updateobj when // the entire document is going to be serialized into a string const string abbreviated(query.toString(false, false), 0, 60); b.append(iscommand ? "command" : "query", abbreviated + "..."); } else if (!iscommand && curop.haveQuery()) { const string abbreviated(curop.query()["query"].toString(false, false), 0, 60); b.append("query", abbreviated + "..."); } if (!updateobj.isEmpty()) { const string abbreviated(updateobj.toString(false, false), 0, 60); b.append("updateobj", abbreviated + "..."); } return false; } if (!query.isEmpty()) { b.append(iscommand ? "command" : "query", query); } else if (!iscommand && curop.haveQuery()) { curop.appendQuery(b, "query"); } if (!updateobj.isEmpty()) { b.append("updateobj", updateobj); } const bool moved = (nmoved >= 1); OPDEBUG_APPEND_NUMBER( cursorid ); OPDEBUG_APPEND_NUMBER( ntoreturn ); OPDEBUG_APPEND_NUMBER( ntoskip ); OPDEBUG_APPEND_BOOL( exhaust ); OPDEBUG_APPEND_NUMBER( nscanned ); OPDEBUG_APPEND_BOOL( idhack ); OPDEBUG_APPEND_BOOL( scanAndOrder ); OPDEBUG_APPEND_BOOL( moved ); OPDEBUG_APPEND_NUMBER( nmoved ); OPDEBUG_APPEND_NUMBER( nMatched ); OPDEBUG_APPEND_NUMBER( nModified ); OPDEBUG_APPEND_NUMBER( ninserted ); OPDEBUG_APPEND_NUMBER( ndeleted ); OPDEBUG_APPEND_BOOL( fastmod ); OPDEBUG_APPEND_BOOL( fastmodinsert ); OPDEBUG_APPEND_BOOL( upsert ); OPDEBUG_APPEND_NUMBER( keyUpdates ); b.appendNumber( "numYield" , curop.numYields() ); b.append( "lockStats" , curop.lockStat().report() ); if ( ! exceptionInfo.empty() ) exceptionInfo.append( b , "exception" , "exceptionCode" ); OPDEBUG_APPEND_NUMBER( nreturned ); OPDEBUG_APPEND_NUMBER( responseLength ); b.append( "millis" , executionTime ); execStats.append(b, "execStats"); return true; }