Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 60 additions & 2 deletions src/sentry/grouping/grouping_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any

from sentry.grouping.strategies.base import StrategyConfiguration
from sentry.grouping.variants import BaseVariant
from sentry.grouping.variants import BaseVariant, ComponentVariant, SaltedComponentVariant
from sentry.models.project import Project
from sentry.services.eventstore.models import Event, GroupEvent
from sentry.utils import metrics
Expand Down Expand Up @@ -63,6 +63,57 @@ def _check_for_mismatched_hashes(
metrics.incr("event_grouping_info.hash_match")


def _get_new_description(variant: BaseVariant) -> str:
"""
Get a human-readable description of the grouping method for use in the grouping info section of
the issue details page.

TODO: As a first step, we're replacing the description only in grouping info, at the last minute
before we return the API response. Once we switch to using key rather than description
elsewhere, this can replace the existing `description` logic.
"""

description_by_key = {
"built_in_fingerprint": "Sentry-defined fingerprint",
"chained_exception_message": "chained exception messages",
"chained_exception_stacktrace": "chained exception stacktraces",
"chained_exception_type": "chained exception types",
"checksum": "checksum",
"csp_local_script_violation": "directive",
"csp_url": "directive and URL",
"custom_fingerprint": "custom fingerprint",
"exception_message": "exception message",
"exception_stacktrace": "exception stacktrace",
"exception_type": "exception type",
"expect_ct": "hostname",
"expect_staple": "hostname",
"fallback": "fallback grouping",
"hashed_checksum": "hashed checksum",
"hpkp": "hostname",
"message": "message",
"ns_error": "NSError",
"stacktrace": "event-level stacktrace",
"template": "filename and context line",
"thread_stacktrace": "thread stacktrace",
}
variant_name = variant.variant_name
# For component variants, we grab the key from the root component rather than the variant itself
# because that way we don't have to strip off variant name and (in the case of salted component
# variants) the hybrid fingerprint designation. (We handle both of those separately below.)
key = variant.root_component.key if isinstance(variant, ComponentVariant) else variant.key
grouping_method = description_by_key[key]

description_parts = [grouping_method]
if "stacktrace" in key and variant_name in ["app", "system"]:
stacktrace_descriptor = "— in-app frames" if variant_name == "app" else "— all frames"
description_parts.append(stacktrace_descriptor)

if isinstance(variant, SaltedComponentVariant):
description_parts.append("and custom fingerprint")

return " ".join(description_parts)


def get_grouping_info_from_variants(
variants: dict[str, BaseVariant],
# Shim to keep the output (which we also use for getting the Seer stacktrace string) stable
Expand All @@ -78,4 +129,11 @@ def get_grouping_info_from_variants(
if use_legacy_format:
return {key: {"key": key, **variant.as_dict()} for key, variant in variants.items()}

return {variant.key: variant.as_dict() for variant in variants.values()}
return {
# Overwrite the description with a new, improved version
variant.key: {
**variant.as_dict(),
"description": _get_new_description(variant),
}
for variant in variants.values()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
created: '2025-10-03T22:58:44.704248+00:00'
created: '2025-10-06T21:57:32.649693+00:00'
creator: sentry
source: tests/sentry/grouping/test_grouping_info.py
---
Expand Down Expand Up @@ -2605,7 +2605,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": true,
"description": "in-app exception stacktrace",
"description": "exception stacktrace — in-app frames",
"hash": "738e7d2503464bc264b4f791286f5122",
"hint": null,
"key": "app_exception_stacktrace",
Expand Down Expand Up @@ -5212,7 +5212,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": true,
"description": "exception stacktrace",
"description": "exception stacktrace — all frames",
"hash": "19a96e0438d28e48355653def82f887a",
"hint": null,
"key": "system_exception_stacktrace",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
created: '2025-10-03T22:58:44.737894+00:00'
created: '2025-10-07T22:42:53.838129+00:00'
creator: sentry
source: tests/sentry/grouping/test_grouping_info.py
---
Expand Down Expand Up @@ -3934,7 +3934,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": false,
"description": "in-app",
"description": "exception message",
"hash": null,
"hint": "ignored because system exception takes precedence",
"key": "app_exception_message",
Expand Down Expand Up @@ -7870,7 +7870,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": true,
"description": "exception stacktrace",
"description": "exception stacktrace — all frames",
"hash": "2552498cfe69a6ddf1dcdde5440ce9c3",
"hint": null,
"key": "system_exception_stacktrace",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
created: '2025-10-03T22:58:44.759841+00:00'
created: '2025-10-06T21:57:32.694439+00:00'
creator: sentry
source: tests/sentry/grouping/test_grouping_info.py
---
Expand Down Expand Up @@ -1093,7 +1093,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": true,
"description": "in-app exception stacktrace",
"description": "exception stacktrace — in-app frames",
"hash": "228c649a3aa0901622c0a0e66ab0522c",
"hint": null,
"key": "app_exception_stacktrace",
Expand Down Expand Up @@ -1138,7 +1138,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": false,
"description": "default",
"description": "message",
"hash": null,
"hint": "ignored because app/system exception takes precedence",
"key": "message",
Expand Down Expand Up @@ -2233,7 +2233,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": true,
"description": "exception stacktrace",
"description": "exception stacktrace — all frames",
"hash": "4ccd0f1953483581ba360c7518f90332",
"hint": null,
"key": "system_exception_stacktrace",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
created: '2025-10-03T22:58:44.777723+00:00'
created: '2025-10-06T21:57:32.710788+00:00'
creator: sentry
source: tests/sentry/grouping/test_grouping_info.py
---
Expand Down Expand Up @@ -143,7 +143,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": true,
"description": "in-app thread stacktrace",
"description": "thread stacktrace — in-app frames",
"hash": "ff6c4ee7c54f118a9647ee86f0c2b0b0",
"hint": null,
"key": "app_thread_stacktrace",
Expand Down Expand Up @@ -188,7 +188,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": false,
"description": "default",
"description": "message",
"hash": null,
"hint": "ignored because app threads take precedence",
"key": "message",
Expand Down Expand Up @@ -333,7 +333,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": false,
"description": "system",
"description": "thread stacktrace — all frames",
"hash": null,
"hint": "ignored because app threads take precedence",
"key": "system_thread_stacktrace",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
created: '2025-10-03T22:58:44.796412+00:00'
created: '2025-10-07T22:42:53.893117+00:00'
creator: sentry
source: tests/sentry/grouping/test_grouping_info.py
---
Expand Down Expand Up @@ -306,7 +306,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": false,
"description": "in-app",
"description": "exception message",
"hash": null,
"hint": "ignored because system exception takes precedence",
"key": "app_exception_message",
Expand Down Expand Up @@ -614,7 +614,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": true,
"description": "exception stacktrace",
"description": "exception stacktrace — all frames",
"hash": "d9c9b0f9ba46e32fddd7cd1512fad235",
"hint": null,
"key": "system_exception_stacktrace",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
created: '2025-10-06T22:48:50.594615+00:00'
created: '2025-10-07T22:42:53.925077+00:00'
creator: sentry
source: tests/sentry/grouping/test_grouping_info.py
---
Expand Down Expand Up @@ -103,15 +103,15 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": false,
"description": "in-app",
"description": "exception message",
"hash": null,
"hint": "ignored because built-in fingerprint takes precedence",
"key": "app_exception_message",
"type": "component"
},
"built_in_fingerprint": {
"contributes": true,
"description": "Sentry defined fingerprint",
"description": "Sentry-defined fingerprint",
"hash": "5d731dcf8ecc4f042eeacf528d8d8da9",
"hint": null,
"key": "built_in_fingerprint",
Expand Down Expand Up @@ -220,7 +220,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": false,
"description": "exception stacktrace",
"description": "exception stacktrace — all frames",
"hash": null,
"hint": "ignored because built-in fingerprint takes precedence",
"key": "system_exception_stacktrace",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
created: '2025-10-06T22:48:50.578017+00:00'
created: '2025-10-07T22:42:53.909474+00:00'
creator: sentry
source: tests/sentry/grouping/test_grouping_info.py
---
Expand Down Expand Up @@ -103,7 +103,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": false,
"description": "in-app",
"description": "exception message",
"hash": null,
"hint": "ignored because built-in fingerprint takes precedence",
"key": "app_exception_message",
Expand All @@ -115,7 +115,7 @@ source: tests/sentry/grouping/test_grouping_info.py
"dogs are great"
],
"contributes": true,
"description": "Sentry defined fingerprint",
"description": "Sentry-defined fingerprint",
"hash": "5d731dcf8ecc4f042eeacf528d8d8da9",
"hint": null,
"key": "built_in_fingerprint",
Expand Down Expand Up @@ -224,7 +224,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": false,
"description": "exception stacktrace",
"description": "exception stacktrace — all frames",
"hash": null,
"hint": "ignored because built-in fingerprint takes precedence",
"key": "system_exception_stacktrace",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
created: '2025-10-03T22:58:44.853310+00:00'
created: '2025-10-06T21:57:32.804736+00:00'
creator: sentry
source: tests/sentry/grouping/test_grouping_info.py
---
Expand Down Expand Up @@ -1071,7 +1071,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": true,
"description": "in-app exception stacktrace",
"description": "exception stacktrace — in-app frames",
"hash": "4ef1fb44d656c3be2a146971f2a222dc",
"hint": null,
"key": "app_exception_stacktrace",
Expand Down Expand Up @@ -2144,7 +2144,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": true,
"description": "exception stacktrace",
"description": "exception stacktrace — all frames",
"hash": "47481871aa8d5ab5729cf2db78ce3032",
"hint": null,
"key": "system_exception_stacktrace",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
created: '2025-10-03T16:56:42.876169+00:00'
created: '2025-10-06T19:13:32.140180+00:00'
creator: sentry
source: tests/sentry/grouping/test_grouping_info.py
---
{
"hashed_checksum": {
"checksum": "de46d023e69b171b90ccf3ebca7aede4",
"contributes": true,
"description": "hashed legacy checksum",
"description": "hashed checksum",
"hash": "de46d023e69b171b90ccf3ebca7aede4",
"hint": null,
"key": "hashed_checksum",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
created: '2025-10-03T16:56:42.891907+00:00'
created: '2025-10-06T19:13:32.155691+00:00'
creator: sentry
source: tests/sentry/grouping/test_grouping_info.py
---
{
"checksum": {
"checksum": "11212012123120120415201309082013",
"contributes": true,
"description": "legacy checksum",
"description": "checksum",
"hash": "11212012123120120415201309082013",
"hint": null,
"key": "checksum",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
created: '2025-10-03T22:58:44.905507+00:00'
created: '2025-10-06T21:57:32.857244+00:00'
creator: sentry
source: tests/sentry/grouping/test_grouping_info.py
---
Expand Down Expand Up @@ -515,7 +515,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": true,
"description": "in-app thread stacktrace",
"description": "thread stacktrace — in-app frames",
"hash": "7c8a196d16b94be382add324be2605ee",
"hint": null,
"key": "app_thread_stacktrace",
Expand Down Expand Up @@ -560,7 +560,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": false,
"description": "default",
"description": "message",
"hash": null,
"hint": "ignored because app/system threads take precedence",
"key": "message",
Expand Down Expand Up @@ -1077,7 +1077,7 @@ source: tests/sentry/grouping/test_grouping_info.py
]
},
"contributes": true,
"description": "thread stacktrace",
"description": "thread stacktrace — all frames",
"hash": "cd7f51d716fd57adc1a5ce1c112e538f",
"hint": null,
"key": "system_thread_stacktrace",
Expand Down
Loading
Loading