| 249 | } |
| 250 | |
| 251 | static JsonBuilderObject getError(const TraceEventFields& errorFields) { |
| 252 | JsonBuilderObject statusObj; |
| 253 | try { |
| 254 | if (errorFields.size()) { |
| 255 | double time = atof(errorFields.getValue("Time").c_str()); |
| 256 | statusObj["time"] = time; |
| 257 | |
| 258 | statusObj["raw_log_message"] = errorFields.toString(); |
| 259 | |
| 260 | std::string type = errorFields.getValue("Type"); |
| 261 | statusObj["type"] = type; |
| 262 | |
| 263 | std::string description = type; |
| 264 | std::string errorName; |
| 265 | if (errorFields.tryGetValue("Error", errorName)) { |
| 266 | statusObj["name"] = errorName; |
| 267 | description += ": " + errorName; |
| 268 | } else |
| 269 | statusObj["name"] = "process_error"; |
| 270 | |
| 271 | struct tm* timeinfo; |
| 272 | time_t t = (time_t)time; |
| 273 | timeinfo = localtime(&t); |
| 274 | char buffer[128]; |
| 275 | strftime(buffer, 128, "%c", timeinfo); |
| 276 | description += " at " + std::string(buffer); |
| 277 | |
| 278 | statusObj["description"] = description; |
| 279 | } |
| 280 | } catch (Error& e) { |
| 281 | TraceEvent(SevError, "StatusGetErrorError").error(e).detail("RawError", errorFields.toString()); |
| 282 | } |
| 283 | return statusObj; |
| 284 | } |
| 285 | |
| 286 | static JsonBuilderObject machineStatusFetcher(WorkerEvents mMetrics, |
| 287 | std::vector<WorkerDetails> workers, |
no test coverage detected