Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit Non Human Readable Names in Kineto #1027

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libkineto/src/output_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ void ChromeTraceLogger::sanitizeStrForJSON(std::string& value) {
value.erase(std::remove(value.begin(), value.end(), '\n'), value.end());
}

static void sanitizeForNonReadableChars(std::string& value) {
for (auto& c : value) {
if (!std::isprint(c)) {
LOG(WARNING) << "Non JSON compliant character found in string: " << value
<< " Replacing with 'unknown'";
value = "unknown";
break;
}
}
}

static inline int32_t sanitizeTid(int32_t tid) {
// Convert all negative tids to its positive value. Create a specific case
// for INT_MIN so it is obvious how it is being handled.
Expand Down Expand Up @@ -521,6 +532,7 @@ void ChromeTraceLogger::handleActivity(const libkineto::ITraceActivity& op) {
// TODO: Remove this once legacy tools are updated.
std::string op_name = op.name() == "kernel" ? "Kernel" : op.name();
sanitizeStrForJSON(op_name);
sanitizeForNonReadableChars(op_name);

// clang-format off
ts = transToRelativeTime(ts);
Expand Down
Loading