Skip to content

Commit

Permalink
add hostnames to metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
hariharan-devarajan committed Oct 4, 2024
1 parent 3a4ce79 commit d54cf7a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions dfanalyzer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ def load_objects(line, fn, time_granularity, time_approximate, condition_fn, loa
d["name"] = val["name"]
if "cat" in val:
d["cat"] = val["cat"]
if "pid" in val:
d["pid"] = val["pid"]
if "tid" in val:
d["tid"] = val["tid"]
if "args" in val and "hhash" in val["args"]:
d["hhash"] = val["args"]["hhash"]
if "M" == val["ph"]:
if d["name"] == "FH":
d["type"] = 1 # 1-> file hash
Expand All @@ -186,17 +192,18 @@ def load_objects(line, fn, time_granularity, time_approximate, condition_fn, loa
if "args" in val and "name" in val["args"] and "value" in val["args"]:
d["name"] = val["args"]["name"]
d["hash"] = val["args"]["value"]
elif d["name"] == "PR":
d["type"] = 5 # 5-> process metadata
if "args" in val and "name" in val["args"] and "value" in val["args"]:
d["name"] = val["args"]["name"]
d["hash"] = val["args"]["value"]
else:
d["type"] = 4 # 4-> others
if "args" in val and "name" in val["args"] and "value" in val["args"]:
d["name"] = val["args"]["name"]
d["value"] = str(val["args"]["value"])
else:
d["type"] = 0 # 0->regular event
if "pid" in val:
d["pid"] = val["pid"]
if "tid" in val:
d["tid"] = val["tid"]
if "dur" in val:
val["dur"] = int(val["dur"])
val["ts"] = int(val["ts"])
Expand Down Expand Up @@ -261,8 +268,6 @@ def io_function(json_object, current_dict, time_approximate,condition_fn):
if "args" in json_object:
if "fhash" in json_object["args"]:
d["fhash"] = json_object["args"]["fhash"]
if "hhash" in json_object["args"]:
d["hhash"] = json_object["args"]["hhash"]

if "POSIX" == json_object["cat"] and "ret" in json_object["args"]:
size = int(json_object["args"]["ret"])
Expand Down
4 changes: 2 additions & 2 deletions src/dftracer/writer/chrome_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ void dftracer::ChromeWriter::convert_json_metadata(
if (is_string) {
written_size = sprintf(
buffer.data() + current_index,
R"(%s{"id":%d,"name":"%s","cat":"dftracer","pid":%lu,"tid":%lu,"ph":"M","args":{"name":"%s","value":"%s"}})",
R"(%s{"id":%d,"name":"%s","cat":"dftracer","pid":%lu,"tid":%lu,"ph":"M","args":{"hhash":%d,"name":"%s","value":"%s"}})",
is_first_char, index, ph, process_id, thread_id, name, value);
} else {
written_size = sprintf(
buffer.data() + current_index,
R"(%s{"id":%d,"name":"%s","cat":"dftracer","pid":%lu,"tid":%lu,"ph":"M","args":{"name":"%s","value":%s}})",
R"(%s{"id":%d,"name":"%s","cat":"dftracer","pid":%lu,"tid":%lu,"ph":"M","args":{"hhash":%d,"name":"%s","value":%s}})",
is_first_char, index, ph, process_id, thread_id, name, value);
}
current_index += written_size;
Expand Down

0 comments on commit d54cf7a

Please sign in to comment.