Skip to content

Commit 6a85d2c

Browse files
authored
chore(autofix): Include more info in errors in trace (#87231)
Include error msg and transaction for more context
1 parent 0c24041 commit 6a85d2c

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/sentry/seer/autofix.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,19 @@ def _get_trace_tree_for_event(event: Event | GroupEvent, project: Project) -> di
148148
if span_id:
149149
span_to_transaction[span_id] = event_node
150150
else:
151+
title = event.title
152+
message = event.message if event.message != event.title else None
153+
transaction_name = event.transaction
154+
155+
error_title = message or ""
156+
if title:
157+
error_title += f"{' - ' if error_title else ''}{title}"
158+
if transaction_name:
159+
error_title += f"{' - ' if error_title else ''}occurred in {transaction_name}"
160+
151161
event_node.update(
152162
{
153-
"title": event.title,
163+
"title": error_title,
154164
"platform": event.platform,
155165
"is_current_project": event.project_id == project.id,
156166
}

tests/sentry/seer/test_autofix.py

+22
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ def test_get_trace_tree_for_event(self):
263263
mock_event.platform = event_data["platform"]
264264
mock_event.project_id = event_data["project_id"]
265265
mock_event.trace_id = trace_id
266+
mock_event.message = event_data.get("message", event_data["title"])
267+
mock_event.transaction = event_data.get("transaction", None)
266268
error_events.append(mock_event)
267269

268270
# Update to patch both Transactions and Events dataset calls
@@ -404,6 +406,8 @@ def test_get_trace_tree_out_of_order_processing(self, mock_get_events):
404406
child_event.platform = "python"
405407
child_event.project_id = self.project.id
406408
child_event.trace_id = trace_id
409+
child_event.message = "Child First"
410+
child_event.transaction = None
407411

408412
# Create proper parent event object
409413
parent_event = Mock()
@@ -424,6 +428,8 @@ def test_get_trace_tree_out_of_order_processing(self, mock_get_events):
424428
parent_event.platform = "python"
425429
parent_event.project_id = self.project.id
426430
parent_event.trace_id = trace_id
431+
parent_event.message = "Parent Last"
432+
parent_event.transaction = None
427433

428434
# Set up the mock to return different results for different dataset calls
429435
def side_effect(filter, dataset=None, **kwargs):
@@ -495,6 +501,8 @@ def test_get_trace_tree_with_only_errors(self, mock_get_events):
495501
error1.platform = "python"
496502
error1.project_id = self.project.id
497503
error1.trace_id = trace_id
504+
error1.message = "First Error"
505+
error1.transaction = None
498506

499507
error2_span_id = "error2-span-id"
500508
error2 = Mock()
@@ -514,6 +522,8 @@ def test_get_trace_tree_with_only_errors(self, mock_get_events):
514522
error2.platform = "python"
515523
error2.project_id = self.project.id
516524
error2.trace_id = trace_id
525+
error2.message = "Second Error"
526+
error2.transaction = None
517527

518528
# This error is a child of error2
519529
error3 = Mock()
@@ -533,6 +543,8 @@ def test_get_trace_tree_with_only_errors(self, mock_get_events):
533543
error3.platform = "python"
534544
error3.project_id = self.project.id
535545
error3.trace_id = trace_id
546+
error3.message = "Child Error"
547+
error3.transaction = None
536548

537549
# Another "orphaned" error with a parent_span_id that doesn't point to anything
538550
error4 = Mock()
@@ -552,6 +564,8 @@ def test_get_trace_tree_with_only_errors(self, mock_get_events):
552564
error4.platform = "python"
553565
error4.project_id = self.project.id
554566
error4.trace_id = trace_id
567+
error4.message = "Orphaned Error"
568+
error4.transaction = None
555569

556570
# Return empty transactions list but populate errors list
557571
def side_effect(filter, dataset=None, **kwargs):
@@ -628,6 +642,8 @@ def test_get_trace_tree_all_relationship_rules(self, mock_get_events):
628642
root_tx.platform = "python"
629643
root_tx.project_id = self.project.id
630644
root_tx.trace_id = trace_id
645+
root_tx.message = "Root Transaction"
646+
root_tx.transaction = "Root Transaction"
631647

632648
# Rule 1: Child whose parent_span_id matches another event's span_id
633649
rule1_child = Mock()
@@ -647,6 +663,8 @@ def test_get_trace_tree_all_relationship_rules(self, mock_get_events):
647663
rule1_child.platform = "python"
648664
rule1_child.project_id = self.project.id
649665
rule1_child.trace_id = trace_id
666+
rule1_child.message = "Rule 1 Child"
667+
rule1_child.transaction = None
650668

651669
# Rule 2: Child whose parent_span_id matches a span in a transaction
652670
rule2_child = Mock()
@@ -666,6 +684,8 @@ def test_get_trace_tree_all_relationship_rules(self, mock_get_events):
666684
rule2_child.platform = "python"
667685
rule2_child.project_id = self.project.id
668686
rule2_child.trace_id = trace_id
687+
rule2_child.message = "Rule 2 Child"
688+
rule2_child.transaction = None
669689

670690
# Rule 3: Child whose span_id matches a span in a transaction
671691
rule3_child = Mock()
@@ -684,6 +704,8 @@ def test_get_trace_tree_all_relationship_rules(self, mock_get_events):
684704
rule3_child.platform = "python"
685705
rule3_child.project_id = self.project.id
686706
rule3_child.trace_id = trace_id
707+
rule3_child.message = "Rule 3 Child"
708+
rule3_child.transaction = None
687709

688710
# Set up the mock to return our test events
689711
def side_effect(filter, dataset=None, **kwargs):

0 commit comments

Comments
 (0)