I put the following code in ShardLocal::_runCommand:
std::string s; StringStackTraceSink sink{s}; printStackTrace(sink); LOGV2(1, "In ShardLocal::_runCommand", "cmd"_attr=cmdObj, "dbName"_attr=dbName, "stacktrace"_attr=s);
The actual location and contents of that log line is probably irrelevant (other than that it contains a stacktrace).
And I have a python script that parses each of those log lines.
But sometimes, the logged message is invalid JSON. There is an issue with the "stacktrace" field of the JSON string. Each time there is an error with it, the JSON object has a field that is
"truncated":{"stacktrace":{"type":"string","size":109042}}
I have attached an example of an invalid log line
Discussion on it here