Created
February 15, 2022 21:54
-
-
Save danhurwit/5a7be3509f300c06041a2b8631ae17bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import operator | |
| def print_span(span): | |
| duration = span.end_time - span.start_time | |
| value = ' ' * span.start_time + '-' * duration | |
| print(value) | |
| def print_nested_spans(parent_id, spans): | |
| children = sorted(list(filter(lambda x: x.parent_id == parent_id, spans)), | |
| key=operator.attrgetter('start_time')) | |
| for child in children: | |
| print_span(child) | |
| print_nested_spans(child.id, spans) | |
| def print_trace(spans): | |
| root_span_id = '' | |
| for span in spans: | |
| if span.parent_id is None: | |
| root_span_id = span.id | |
| print_span(span) | |
| print_nested_spans(root_span_id, spans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment