Skip to content

Commit 753d0d3

Browse files
Ilia Cherniavskiifacebook-github-bot
authored andcommitted
Fix empty metadata invalid json (#173)
Summary: Pull Request resolved: #173 Fix a case of invalid json when metadata is empty Reviewed By: chaekit Differential Revision: D27837639 fbshipit-source-id: 24c80671d8a15ac2d39096d401a5ec05b3339317
1 parent 3cf5ebf commit 753d0d3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

libkineto/src/output_json.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,23 @@ void ChromeTraceLogger::handleCpuActivity(
171171
return;
172172
}
173173

174+
auto metadata = op.getMetadata();
175+
if (!metadata.empty()) {
176+
metadata += ",";
177+
}
174178
// clang-format off
175179
traceOf_ << fmt::format(R"JSON(
176180
{{
177181
"ph": "X", "cat": "Operator", {},
178182
"args": {{
179-
{},
180-
"Device": {}, "External id": {},
183+
{}
184+
"Device": {}, "External id": {},
181185
"Trace name": "{}", "Trace iteration": {}
182186
}}
183187
}},)JSON",
184188
traceActivityJson(op, ""),
185189
// args
186-
op.getMetadata(),
190+
metadata,
187191
op.device, op.correlation,
188192
span.name, span.iteration);
189193
// clang-format on

0 commit comments

Comments
 (0)