Skip to content

Commit

Permalink
graph shows "nice name" that includes "part_number" or "seq"
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm committed Oct 18, 2024
1 parent f34e3ac commit eff9052
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions runners/s3-benchrunner-rust/graph/allspans.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ def draw(data):
name_count = defaultdict(int)
for (idx, span) in enumerate(spans):
name = span['name']
# nice name includes stuff like part-number
nice_name = _nice_name(span)
# we want each span in its own row, so assign a unique name and use that as Y value
# TODO: improve unique name, using "seq" or "part-num"
name_count[name] += 1
unique_name = f"{name}#{name_count[name]}"
name_count[nice_name] += 1
unique_name = f"{nice_name} ({span['spanId']})"

start_time_ns = span['startTimeUnixNano']
end_time_ns = span['endTimeUnixNano']
Expand All @@ -34,21 +35,21 @@ def draw(data):
visual_end_time_ns = start_time_ns + max(duration_ns, 50_000_000)

columns['Name'].append(name)
columns['Nice Name'].append(nice_name)
columns['Unique Name'].append(unique_name)
columns['Start Time'].append(pd.to_datetime(start_time_ns))
columns['End Time'].append(pd.to_datetime(end_time_ns))
columns['Visual End Time'].append(pd.to_datetime(visual_end_time_ns))
columns['Duration (secs)'].append(duration_ns / 1_000_000_000.0)
columns['Index'].append(idx)
columns['Span ID'].append(span['spanId'])
columns['Parent ID'].append(span['parentSpanId'])
columns['Attributes'].append(
"".join([f"<br> {k}={v}" for (k, v) in span['attributes'].items()]))

# if a span name occurs only once, remove the "#1" from its unique name
# if a span name occurs only once, we can just use the nice_name
for (i, name) in enumerate(columns['Name']):
if name_count[name] == 1:
columns['Unique Name'][i] = name
columns['Unique Name'][i] = columns['Nice Name'][i]

df = pd.DataFrame(columns)

Expand Down Expand Up @@ -167,3 +168,14 @@ def _simplify_attributes(attributes_list):
simple_dict[key] = value

return simple_dict


def _nice_name(span):
name = span['name']
attributes = span['attributes']
if (seq := attributes.get('seq')) is not None:
name += f"[{seq}]"

if (part_number := attributes.get('part_number')) is not None:
name += f"#{part_number}"
return name

0 comments on commit eff9052

Please sign in to comment.