Skip to content

Commit b80df71

Browse files
authored
fix(events-trace): Consistent child sort key format (#105186)
Previous debugging lines didn't reveal anything notable. This follows ensures the sort key is consistent for all the different TraceEvent instances.
1 parent a689473 commit b80df71

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/sentry/api/endpoints/organization_events_trace.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -483,24 +483,21 @@ def is_root(item: SnubaTransaction) -> bool:
483483
return item.get("root", "0") == "1"
484484

485485

486-
def child_sort_key(item: TraceEvent) -> list[int | str]:
486+
def child_sort_key(item: TraceEvent) -> tuple[int, int, str, str]:
487487
if item.fetched_nodestore and item.nodestore_event is not None:
488-
return [
488+
return (
489489
item.nodestore_event.data["start_timestamp"],
490490
item.nodestore_event.data["timestamp"],
491-
]
492-
elif item.span_serialized:
493-
return [
494-
item.event["precise.start_ts"],
495-
item.event["precise.finish_ts"],
496491
item.event["transaction"],
497492
item.event["id"],
498-
]
493+
)
499494
else:
500-
return [
495+
return (
496+
item.event["precise.start_ts"],
497+
item.event["precise.finish_ts"],
501498
item.event["transaction"],
502499
item.event["id"],
503-
]
500+
)
504501

505502

506503
def count_performance_issues(
@@ -1322,9 +1319,6 @@ def serialize(
13221319
orphans.extend(result)
13231320
elif len(roots) > 0:
13241321
trace_roots = result
1325-
sentry_sdk.set_context(
1326-
"trace_root_keys", {"keys": [child_sort_key(trace_root) for trace_root in trace_roots]}
1327-
)
13281322
# We sort orphans and roots separately because we always want the root(s) as the first element(s)
13291323
trace_roots.sort(key=child_sort_key)
13301324
orphans.sort(key=child_sort_key)

0 commit comments

Comments
 (0)