Log stack traces for combined CalculatorGraph statuses

PiperOrigin-RevId: 553111356
This commit is contained in:
MediaPipe Team 2023-08-02 05:08:34 -07:00 committed by Copybara-Service
parent 557ed0b1ea
commit 6e54d8c204

View File

@ -75,6 +75,11 @@ namespace {
constexpr int kMaxNumAccumulatedErrors = 1000; constexpr int kMaxNumAccumulatedErrors = 1000;
constexpr char kApplicationThreadExecutorType[] = "ApplicationThreadExecutor"; constexpr char kApplicationThreadExecutorType[] = "ApplicationThreadExecutor";
// Do not log status payloads, but do include stack traces.
constexpr absl::StatusToStringMode kStatusLogFlags =
absl::StatusToStringMode::kWithEverything &
(~absl::StatusToStringMode::kWithPayload);
} // namespace } // namespace
void CalculatorGraph::ScheduleAllOpenableNodes() { void CalculatorGraph::ScheduleAllOpenableNodes() {
@ -707,7 +712,7 @@ absl::Status CalculatorGraph::PrepareForRun(
absl::Status error_status; absl::Status error_status;
if (has_error_) { if (has_error_) {
GetCombinedErrors(&error_status); GetCombinedErrors(&error_status);
LOG(ERROR) << error_status; LOG(ERROR) << error_status.ToString(kStatusLogFlags);
return error_status; return error_status;
} }
@ -786,7 +791,7 @@ absl::Status CalculatorGraph::PrepareForRun(
} }
if (GetCombinedErrors(&error_status)) { if (GetCombinedErrors(&error_status)) {
LOG(ERROR) << error_status; LOG(ERROR) << error_status.ToString(kStatusLogFlags);
CleanupAfterRun(&error_status); CleanupAfterRun(&error_status);
return error_status; return error_status;
} }
@ -850,7 +855,7 @@ absl::Status CalculatorGraph::WaitUntilIdle() {
VLOG(2) << "Scheduler idle."; VLOG(2) << "Scheduler idle.";
absl::Status status = absl::OkStatus(); absl::Status status = absl::OkStatus();
if (GetCombinedErrors(&status)) { if (GetCombinedErrors(&status)) {
LOG(ERROR) << status; LOG(ERROR) << status.ToString(kStatusLogFlags);
} }
return status; return status;
} }
@ -1052,8 +1057,7 @@ void CalculatorGraph::RecordError(const absl::Status& error) {
} }
bool CalculatorGraph::GetCombinedErrors(absl::Status* error_status) { bool CalculatorGraph::GetCombinedErrors(absl::Status* error_status) {
return GetCombinedErrors("CalculatorGraph::Run() failed in Run: ", return GetCombinedErrors("CalculatorGraph::Run() failed: ", error_status);
error_status);
} }
bool CalculatorGraph::GetCombinedErrors(const std::string& error_prefix, bool CalculatorGraph::GetCombinedErrors(const std::string& error_prefix,