Skip to content

Commit

Permalink
ref(seer-grouping): Send group hash to Seer (#70244)
Browse files Browse the repository at this point in the history
This adds the group hash to the outgoing payload sent to Seer. Once this is merged, it will be safe to remove the Seer logic handling an incoming group id, since we'll now be able to rely on the group hash being present. 

Taken together, this PR and the ones leading up to it (links below) mean will mean that on the Sentry side we'll be sending in the request and handling in the response both hash and group id (and transforming hashes in the response into group ids if hashes are all that's sent). Once Seer is adjusted to only deal in hashes, we can then remove the sending and handling of group ids from Sentry and the transition will be complete.

Other PRs which are part of the group-id-to-group-hash switch:
- #70005, #70236, and #70237 - various small fixes and tweaks
- #70070 and #70238 - updates to associated types
- #70240 - automatic conversion from hash to group id when handling Seer similar group data
  • Loading branch information
lobsterkatie committed May 7, 2024
1 parent 78d2f28 commit 874db7e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/sentry/api/endpoints/group_similar_issues_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def get(self, request: Request, group) -> Response:

similar_issues_params: SimilarIssuesEmbeddingsRequest = {
"group_id": group.id,
"group_hash": latest_event.get_primary_hash(),
"project_id": group.project.id,
"stacktrace": stacktrace_string,
"message": group.message,
Expand All @@ -183,6 +184,7 @@ def get(self, request: Request, group) -> Response:
organization_id=group.organization.id,
project_id=group.project.id,
group_id=group.id,
group_hash=latest_event.get_primary_hash(),
count_over_threshold=len(
[
result.stacktrace_distance
Expand Down
20 changes: 20 additions & 0 deletions tests/sentry/api/endpoints/test_group_similar_issues_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,12 +662,14 @@ def test_get_formatted_results(self):
similar_issue_data_1 = SeerSimilarIssueData(
message_distance=0.05,
parent_group_id=NonNone(self.similar_event.group_id),
parent_group_hash=NonNone(self.similar_event.get_primary_hash()),
should_group=True,
stacktrace_distance=0.01,
)
similar_issue_data_2 = SeerSimilarIssueData(
message_distance=0.49,
parent_group_id=NonNone(event_from_second_similar_group.group_id),
parent_group_hash=NonNone(event_from_second_similar_group.get_primary_hash()),
should_group=False,
stacktrace_distance=0.23,
)
Expand Down Expand Up @@ -718,6 +720,7 @@ def test_simple_only_group_id_returned(self, mock_logger, mock_seer_request):

expected_seer_request_params = {
"group_id": self.group.id,
"group_hash": NonNone(self.event.get_primary_hash()),
"project_id": self.project.id,
"stacktrace": EXPECTED_STACKTRACE_STRING,
"message": self.group.message,
Expand Down Expand Up @@ -764,6 +767,7 @@ def test_simple_only_hash_returned(self, mock_logger, mock_seer_request):

expected_seer_request_params = {
"group_id": self.group.id,
"group_hash": NonNone(self.event.get_primary_hash()),
"project_id": self.project.id,
"stacktrace": EXPECTED_STACKTRACE_STRING,
"message": self.group.message,
Expand Down Expand Up @@ -812,6 +816,7 @@ def test_simple_group_id_and_hash_returned(self, mock_logger, mock_seer_request)

expected_seer_request_params = {
"group_id": self.group.id,
"group_hash": NonNone(self.event.get_primary_hash()),
"project_id": self.project.id,
"stacktrace": EXPECTED_STACKTRACE_STRING,
"message": self.group.message,
Expand Down Expand Up @@ -843,18 +848,21 @@ def test_multiple(self, mock_seer_request, mock_record):
{
"message_distance": 0.05,
"parent_group_id": NonNone(self.similar_event.group_id),
"parent_group_hash": NonNone(self.similar_event.get_primary_hash()),
"should_group": True,
"stacktrace_distance": 0.002, # Over threshold
},
{
"message_distance": 0.05,
"parent_group_id": NonNone(over_threshold_group_event.group_id),
"parent_group_hash": NonNone(over_threshold_group_event.get_primary_hash()),
"should_group": True,
"stacktrace_distance": 0.002, # Over threshold
},
{
"message_distance": 0.05,
"parent_group_id": NonNone(under_threshold_group_event.group_id),
"parent_group_hash": NonNone(under_threshold_group_event.get_primary_hash()),
"should_group": False,
"stacktrace_distance": 0.05, # Under threshold
},
Expand Down Expand Up @@ -883,6 +891,7 @@ def test_multiple(self, mock_seer_request, mock_record):
organization_id=self.org.id,
project_id=self.project.id,
group_id=self.group.id,
group_hash=NonNone(self.event.get_primary_hash()),
count_over_threshold=2,
user_id=self.user.id,
)
Expand All @@ -898,6 +907,7 @@ def test_incomplete_return_data(self, mock_seer_request, mock_logger):
{
"message_distance": 0.05,
"parent_group_id": NonNone(self.similar_event.group_id),
"parent_group_hash": NonNone(self.similar_event.get_primary_hash()),
"should_group": True,
"stacktrace_distance": 0.01,
},
Expand All @@ -917,6 +927,7 @@ def test_incomplete_return_data(self, mock_seer_request, mock_logger):
extra={
"request_params": {
"group_id": NonNone(self.event.group_id),
"group_hash": NonNone(self.event.get_primary_hash()),
"project_id": self.project.id,
"stacktrace": EXPECTED_STACKTRACE_STRING,
"message": self.group.message,
Expand Down Expand Up @@ -947,12 +958,14 @@ def test_nonexistent_group(self, mock_seer_request, mock_logger):
{
"message_distance": 0.05,
"parent_group_id": NonNone(self.similar_event.group_id),
"parent_group_hash": NonNone(self.similar_event.get_primary_hash()),
"should_group": True,
"stacktrace_distance": 0.01,
},
{
"message_distance": 0.05,
"parent_group_id": 1121201212312012, # too high to be real
"parent_group_hash": "not a real hash",
"should_group": True,
"stacktrace_distance": 0.01,
},
Expand All @@ -966,13 +979,15 @@ def test_nonexistent_group(self, mock_seer_request, mock_logger):
extra={
"request_params": {
"group_id": NonNone(self.event.group_id),
"group_hash": NonNone(self.event.get_primary_hash()),
"project_id": self.project.id,
"stacktrace": EXPECTED_STACKTRACE_STRING,
"message": self.group.message,
},
"raw_similar_issue_data": {
"message_distance": 0.05,
"parent_group_id": 1121201212312012,
"parent_group_hash": "not a real hash",
"should_group": True,
"stacktrace_distance": 0.01,
},
Expand All @@ -995,6 +1010,7 @@ def test_empty_seer_return(self, mock_seer_request, mock_record):
organization_id=self.org.id,
project_id=self.project.id,
group_id=self.group.id,
group_hash=NonNone(self.event.get_primary_hash()),
count_over_threshold=0,
user_id=self.user.id,
)
Expand Down Expand Up @@ -1063,6 +1079,7 @@ def test_no_optional_params(self, mock_seer_request):
{
"message_distance": 0.05,
"parent_group_id": NonNone(self.similar_event.group_id),
"parent_group_hash": NonNone(self.similar_event.get_primary_hash()),
"should_group": True,
"stacktrace_distance": 0.01,
}
Expand All @@ -1083,6 +1100,7 @@ def test_no_optional_params(self, mock_seer_request):
body=json.dumps(
{
"group_id": self.group.id,
"group_hash": NonNone(self.event.get_primary_hash()),
"project_id": self.project.id,
"stacktrace": EXPECTED_STACKTRACE_STRING,
"message": self.group.message,
Expand All @@ -1106,6 +1124,7 @@ def test_no_optional_params(self, mock_seer_request):
body=json.dumps(
{
"group_id": self.group.id,
"group_hash": NonNone(self.event.get_primary_hash()),
"project_id": self.project.id,
"stacktrace": EXPECTED_STACKTRACE_STRING,
"message": self.group.message,
Expand All @@ -1130,6 +1149,7 @@ def test_no_optional_params(self, mock_seer_request):
body=json.dumps(
{
"group_id": self.group.id,
"group_hash": NonNone(self.event.get_primary_hash()),
"project_id": self.project.id,
"stacktrace": EXPECTED_STACKTRACE_STRING,
"message": self.group.message,
Expand Down
4 changes: 4 additions & 0 deletions tests/sentry/seer/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def test_simple_similar_issues_embeddings_only_group_id_returned(

params: SimilarIssuesEmbeddingsRequest = {
"group_id": NonNone(event.group_id),
"group_hash": NonNone(event.get_primary_hash()),
"project_id": default_project.id,
"stacktrace": "string",
"message": "message",
Expand All @@ -106,6 +107,7 @@ def test_simple_similar_issues_embeddings_only_hash_returned(mock_seer_request,

params: SimilarIssuesEmbeddingsRequest = {
"group_id": NonNone(event.group_id),
"group_hash": NonNone(event.get_primary_hash()),
"project_id": default_project.id,
"stacktrace": "string",
"message": "message",
Expand Down Expand Up @@ -142,6 +144,7 @@ def test_simple_similar_issues_embeddings_both_returned(mock_seer_request, defau

params: SimilarIssuesEmbeddingsRequest = {
"group_id": NonNone(event.group_id),
"group_hash": NonNone(event.get_primary_hash()),
"project_id": default_project.id,
"stacktrace": "string",
"message": "message",
Expand All @@ -160,6 +163,7 @@ def test_empty_similar_issues_embeddings(mock_seer_request, default_project):

params: SimilarIssuesEmbeddingsRequest = {
"group_id": NonNone(event.group_id),
"group_hash": NonNone(event.get_primary_hash()),
"project_id": default_project.id,
"stacktrace": "string",
"message": "message",
Expand Down

0 comments on commit 874db7e

Please sign in to comment.