Skip to content
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): API to find groups caused by the same root error #66992

Merged
merged 21 commits into from
Mar 25, 2024

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Mar 14, 2024

This adds an API which will return all groups that are related to an issue.

For now, it will only show groups that have the same error type and title. It will likely need more polishing as we look at real-life examples.

This also lays the ground for adding other heuristics like trace-connected errors.

@armenzg armenzg self-assigned this Mar 14, 2024
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 14, 2024
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
src/sentry/api/endpoints/issues/related_issues.py Outdated Show resolved Hide resolved
src/sentry/issues/related/README.md Outdated Show resolved Hide resolved

def match_criteria(a: dict[str, str | None], b: dict[str, str | None]) -> bool:
# XXX: In future iterations we will be able to use similar titles rather than an exact match
return a["type"] == b["type"] and a["title"] == b["title"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very simplistic but it works in a lot of cases.

def test_same_root_related_issues(self) -> None:
# This is the group we're going to query about
group = self.create_group(data=self._data(self.error_type, self.error_value))
self.group_id = group.id
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will allow reverse_url to point to this specific group.

@armenzg armenzg marked this pull request as ready for review March 15, 2024 13:24
@armenzg armenzg requested review from a team as code owners March 15, 2024 13:24
@armenzg armenzg changed the title WIP - feat(related_issues): API to find groups caused by the same root error feat(related_issues): API to find groups caused by the same root error Mar 21, 2024
def same_root_cause_analysis(group: Group) -> list[Group]:
"""Analyze and create a group set if the group was caused by the same root cause."""
# XXX: This function is not optimal since we can't query the data field which is a GzippedDictField
project_groups = Group.objects.filter(project=group.project_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unbounded, you should use RangeQuerySetWrapper here and also limit the number of groups returned

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would also probably be helpful to just fetch the fields you need rather than the entire Group

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Thanks, Dan!

@armenzg armenzg requested a review from a team as a code owner March 25, 2024 14:19
@@ -480,24 +480,24 @@ static/app/components/events/eventStatisticalDetector/ @getse


## Issues
**/issues/** @getsentry/issues
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches all paths that contain the issues directory. I've tested it.

@@ -480,24 +480,24 @@ static/app/components/events/eventStatisticalDetector/ @getse


## Issues
**/issues/** @getsentry/issues
/src/sentry/api/helpers/source_map_helper.py @getsentry/issues
/src/sentry/api/helpers/actionable_items_helper.py @getsentry/issues
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I make an explicit comment, I'm just re-ordering the list alphabetically.

/src/sentry/event_manager.py @getsentry/issues
/src/sentry/grouping/ @getsentry/issues
/src/sentry/issues/ @getsentry/issues
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing. It is now matched by the global matcher at the top.

/tests/sentry/event_manager/ @getsentry/issues
/tests/sentry/grouping/ @getsentry/issues
/tests/sentry/issues/ @getsentry/issues
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing. It is now matched by the global matcher at the top.

"""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
project_groups = RangeQuerySetWrapper(Group.objects.filter(project=group.project_id), limit=100)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've addressed Dan's concern and started using RangeQuerySetWrapper

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're limiting to 100 rows total you don't need the ranged wrapper, the limit is enough.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. This is not a permanent change. I will tweak it later.

"""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
project_groups = RangeQuerySetWrapper(Group.objects.filter(project=group.project_id), limit=100)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're limiting to 100 rows total you don't need the ranged wrapper, the limit is enough.

@armenzg armenzg merged commit 382d776 into master Mar 25, 2024
49 checks passed
@armenzg armenzg deleted the feat/same-root/related_issues/armenzg branch March 25, 2024 17:18
armenzg added a commit that referenced this pull request Mar 26, 2024
PR #66992 added an API to show related issues with the same error type and title.

This change adds a Related Issues tab to the Issue Details page in order to show those related issues.

This change is behind a feature flag while we polish it.

Currently the list of related issues does not allow for taking actions but that will come in a following change.
armenzg added a commit that referenced this pull request Mar 28, 2024
…#67079)

This PR depends on #66992 which adds the API to related issues.

---------

Co-authored-by: Scott Cooper <[email protected]>
Co-authored-by: Malachi Willey <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 10, 2024
@armenzg armenzg added this to the Related Issues - V1 milestone Apr 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants