Skip to content

Commit

Permalink
Automatic doctor run: adding scuba event for run status
Browse files Browse the repository at this point in the history
Summary:
Follow up diff for D63265563.

## This change
Add scuba logs for doctor run status

## Query
https://fburl.com/daiquery/8tyonop2

Differential Revision: D65039167

fbshipit-source-id: 7b168ba58d2392e9fb97f0c6b75382399e142749
  • Loading branch information
Saurav Prakash authored and facebook-github-bot committed Oct 29, 2024
1 parent ee478b5 commit 969162e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
13 changes: 12 additions & 1 deletion eden/fs/service/EdenServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2761,7 +2761,10 @@ void EdenServer::runEdenDoctor() {
folly::CPUThreadPoolExecutor executor(1);
auto systemConfigDir = config_->getEdenConfig()->getSystemConfigDir();
auto edenDir = getEdenDir();
executor.add([systemConfigDir, edenDir] {
auto structuredLogger = structuredLogger_;
executor.add([systemConfigDir, edenDir, structuredLogger] {
auto doctorRunStatus = AutoEdenDoctorRunEvent::Success;
auto statusReason = std::string();
try {
XLOG(INFO, "Running periodic eden doctor dry-run.");
// Not passing Options field cause "0x57" error. ref: D59783277
Expand Down Expand Up @@ -2794,11 +2797,19 @@ void EdenServer::runEdenDoctor() {
XLOG(
ERR,
"EdenFS doctor dry run failed or timed-out. Check edenfs doctor scuba logs for more info.");
doctorRunStatus = AutoEdenDoctorRunEvent::TimeoutOrFailure;
}
} catch (const std::exception& e) {
XLOG(ERR)
<< "Exception occurred while trying to run periodic doctor dry-run: "
<< e.what();
doctorRunStatus = AutoEdenDoctorRunEvent::ProcessCreationFailure;
statusReason = e.what();
}

if (structuredLogger) {
structuredLogger->logEvent(
AutoEdenDoctorRunEvent{doctorRunStatus, statusReason});
}
});
}
Expand Down
39 changes: 39 additions & 0 deletions eden/fs/telemetry/LogEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,4 +752,43 @@ struct FileAccessEvent : public EdenFSFileAccessEvent {
}
};

/**
* Used to log status of automatic doctor runs
*/
struct AutoEdenDoctorRunEvent : public EdenFSEvent {
enum RunStatus : uint8_t {
Success = 0,
ProcessCreationFailure = 1,
TimeoutOrFailure = 2
};

RunStatus run_status;
std::string failure_reason;

explicit AutoEdenDoctorRunEvent(
RunStatus run_status,
std::string failure_reason)
: run_status(run_status), failure_reason(std::move(failure_reason)) {}

void populate(DynamicEvent& event) const override {
if (run_status == Success) {
event.addString("run_status", "Success");
} else if (run_status == ProcessCreationFailure) {
event.addString("run_status", "ProcessCreationFailure");
} else if (run_status == TimeoutOrFailure) {
event.addString("run_status", "TimeoutOrFailure");
} else {
// Logging numerical value in case there is no string mapping here
event.addString("run_status", std::to_string(run_status));
}

// Re-using existing column
event.addString("reason", failure_reason);
}

const char* getType() const override {
return "auto_eden_doctor_run_events";
}
};

} // namespace facebook::eden

0 comments on commit 969162e

Please sign in to comment.