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): Include event and trace IDs for trace-connected errors #69693

Merged
merged 3 commits into from
Apr 26, 2024

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Apr 25, 2024

For trace-connected errors, we look for the recommended event for a group and we look for a trace ID. Based on that trace ID, we determine what issues happened during the related trace.

Exposing this data in the API will help the customer visit the trace used to relate the issues.

…ed errors

This information can be used by the UI to show what trace or event were used to determine the trace connected errors.
@armenzg armenzg self-assigned this Apr 25, 2024
@armenzg armenzg requested a review from a team as a code owner April 25, 2024 19:15
@armenzg armenzg added this to the Related Issues - V1 milestone Apr 25, 2024
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 25, 2024
for key, func in RELATED_ISSUES_ALGORITHMS.items():
related_issues.append({"type": key, "data": func(group)})
data, meta = func(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.

The function now returns a tuple with some meta data.

"data": [another_proj_event.group_id],
"meta": {
"event_id": error_event.event_id,
"trace_id": error_event.trace_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.

These two pieces of information can now be used in the UI.

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.82%. Comparing base (522b3a1) to head (8902a70).
Report is 36 commits behind head on master.

❗ Current head 8902a70 differs from pull request most recent head 2865960. Consider uploading reports for the commit 2865960 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #69693       +/-   ##
===========================================
+ Coverage   51.80%   79.82%   +28.01%     
===========================================
  Files        6453     6478       +25     
  Lines      286715   287906     +1191     
  Branches    49438    49624      +186     
===========================================
+ Hits       148540   229814    +81274     
+ Misses     137779    57700    -80079     
+ Partials      396      392        -4     
Files Coverage Δ
src/sentry/api/endpoints/issues/related_issues.py 100.00% <100.00%> (+11.11%) ⬆️
src/sentry/issues/related/__init__.py 100.00% <100.00%> (+36.36%) ⬆️
src/sentry/issues/related/same_root_cause.py 100.00% <100.00%> (+50.00%) ⬆️
src/sentry/issues/related/trace_connected.py 100.00% <100.00%> (+52.63%) ⬆️

... and 2065 files with indirect coverage changes

Copy link
Member

@leeandher leeandher left a comment

Choose a reason for hiding this comment

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

Looks good! Have some typing suggestions but they aren't blocking, code wise it's great and I appreciate adding the missing doc string!

src/sentry/issues/related/__init__.py Show resolved Hide resolved
@@ -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]]]:
Copy link
Member

@leeandher leeandher Apr 26, 2024

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:

class RelatedIssueItem(TypedDict):
  meta: something
  type: str
  data: something
  
def find_related_issues(group: Group) -> list[RelatedIssueItem]

But I'll leave the specific types to you!

@@ -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]]:
Copy link
Member

Choose a reason for hiding this comment

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

I personally like dict returns since they have to name each return value, but either way I think we should extract this to a type alias and reuse it for both algos, maybe even typing RELATED_ISSUES_ALGORITHMS explicitly so that new entries to that dict have a blueprint.

@armenzg armenzg merged commit 29b6f63 into master Apr 26, 2024
48 checks passed
@armenzg armenzg deleted the feat/return-event-and-trace-id/armenzg branch April 26, 2024 15:33
@armenzg
Copy link
Member Author

armenzg commented Apr 26, 2024

I will follow up on the typing suggestions in the next PR!

Copy link

sentry-io bot commented May 8, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ SnubaError: HTTPConnectionPool(host='127.0.0.1', port=10006): Read timed out. (read timeout=30) /api/0/issues/{issue_id}/related-issues/ View Issue

Did you find this useful? React with a 👍 or 👎

@github-actions github-actions bot locked and limited conversation to collaborators May 24, 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