-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(related_issues): Include event and trace IDs for trace-connected errors #69693
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,10 @@ | |
} | ||
|
||
|
||
def find_related_issues(group: Group) -> list[dict[str, list[int] | str]]: | ||
related_issues: list[dict[str, list[int] | str]] = [] | ||
def find_related_issues(group: Group) -> list[dict[str, str | list[int] | dict[str, str]]]: | ||
related_issues: list[dict[str, str | list[int] | dict[str, str]]] = [] | ||
leeandher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for key, func in RELATED_ISSUES_ALGORITHMS.items(): | ||
related_issues.append({"type": key, "data": func(group)}) | ||
data, meta = func(group) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function now returns a tuple with some meta data. |
||
related_issues.append({"type": key, "data": data, "meta": meta}) | ||
|
||
return related_issues |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
from sentry.utils.query import RangeQuerySetWrapper | ||
|
||
|
||
def same_root_cause_analysis(group: Group) -> list[int]: | ||
def same_root_cause_analysis(group: Group) -> tuple[list[int], dict[str, str]]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally like |
||
"""Analyze and create a group set if the group was caused by the same root cause.""" | ||
# Querying the data field (which is a GzippedDictField) cannot be done via | ||
# Django's ORM, thus, we do so via compare_groups | ||
|
@@ -16,7 +16,7 @@ def same_root_cause_analysis(group: Group) -> list[int]: | |
limit=100, | ||
) | ||
same_error_type_groups = [g.id for g in project_groups if compare_groups(g, group)] | ||
return same_error_type_groups or [] | ||
return same_error_type_groups or [], {} | ||
|
||
|
||
def compare_groups(groupA: Group, groupB: Group) -> bool: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,22 +46,34 @@ def test_same_root_related_issues(self) -> None: | |
# https://us.sentry.io/api/0/organizations/sentry/issues-stats/?groups=4741828952&groups=4489703641&statsPeriod=24h | ||
assert response.json() == { | ||
"data": [ | ||
{"type": "same_root_cause", "data": [5]}, | ||
{"type": "trace_connected", "data": []}, | ||
{"type": "same_root_cause", "data": [5], "meta": {}}, | ||
{"type": "trace_connected", "data": [], "meta": {}}, | ||
], | ||
} | ||
|
||
def test_trace_connected_errors(self) -> None: | ||
error_event, _, another_proj_event = self.load_errors(self.project, uuid4().hex[:16]) | ||
group = error_event.group | ||
self.group_id = error_event.group_id # type: ignore[assignment] | ||
recommended_event = group.get_recommended_event_for_environments() # type: ignore[union-attr] | ||
assert recommended_event is not None # It helps with typing | ||
|
||
assert error_event.group_id != another_proj_event.group_id | ||
assert error_event.project.id != another_proj_event.project.id | ||
assert error_event.trace_id == another_proj_event.trace_id | ||
|
||
response = self.get_success_response() | ||
assert response.json() == { | ||
"data": [ | ||
{"type": "same_root_cause", "data": []}, | ||
{"type": "trace_connected", "data": [another_proj_event.group_id]}, | ||
{"type": "same_root_cause", "data": [], "meta": {}}, | ||
{ | ||
"type": "trace_connected", | ||
# This is the other issue in the trace that it is not itself | ||
"data": [another_proj_event.group_id], | ||
"meta": { | ||
"event_id": recommended_event.event_id, | ||
"trace_id": error_event.trace_id, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two pieces of information can now be used in the UI. |
||
}, | ||
}, | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For here it looks like we can use a typed dict:
But I'll leave the specific types to you!