diff --git a/runners/s3-benchrunner-rust/graph/allspans.py b/runners/s3-benchrunner-rust/graph/allspans.py index 8eb1d83..1c6ec0f 100644 --- a/runners/s3-benchrunner-rust/graph/allspans.py +++ b/runners/s3-benchrunner-rust/graph/allspans.py @@ -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'] @@ -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"
{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) @@ -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