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
5 changes: 5 additions & 0 deletions src/sentry/grouping/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def __init__(self, strategy_config: StrategyConfiguration, event: Event):
self.canonical_event_message = event_message
self.canonical_message_parameterized = parameterizer.parameterize(event_message)

# Track use of the cached values for metrics purposes. Any use past the first one signifies
# a reuse of the value, thus proving caching worthwhile.
self.cached_parameterizer_used = False
self.cached_param_result_used = False

self._push_context_layer()

def __setitem__(self, key: str, value: Any) -> None:
Expand Down
4 changes: 4 additions & 0 deletions src/sentry/grouping/fingerprinting/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from sentry.stacktraces.functions import get_function_name_for_frame
from sentry.stacktraces.platform import get_behavior_family_for_platform
from sentry.stacktraces.processing import get_crash_frame_from_event_data
from sentry.utils import metrics
from sentry.utils.event_frames import find_stack_frames
from sentry.utils.safe import get_path
from sentry.utils.tag_normalization import normalized_sdk_tag_from_event
Expand Down Expand Up @@ -340,6 +341,9 @@ def expand_title_template(
) -> str:
def _handle_match(match: re.Match[str]) -> str:
variable_key = match.group(1)
if variable_key == "message":
metrics.incr("grouping.message_used", tags={"reason": "custom_title"})

# TODO: Once we have fully transitioned off of the `newstyle:2023-01-11` grouping config, we
# can remove `use_legacy_unknown_variable_handling` and just return the value given by
# `resolve_fingerprint_variable`
Expand Down
5 changes: 5 additions & 0 deletions src/sentry/grouping/parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ def _handle_regex_match(match: re.Match[str]) -> str:

parameterized = self._parameterization_regex.sub(_handle_regex_match, input_str)

metrics.incr(
"grouping.parameterizer_called",
tags={"changed": parameterized != input_str, "experimental": self._experimental},
)

for key, value in matches_counter.items():
# Track the kinds of replacements being made
metrics.incr("grouping.value_parameterized", amount=value, tags={"key": key})
Expand Down
22 changes: 19 additions & 3 deletions src/sentry/grouping/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,29 @@ def normalize_message_for_grouping(
"""
if message == context.canonical_event_message:
parameterized = context.canonical_message_parameterized

# Before we mark the value as having been used, check if it's already marked that way. If
# so, that means our use of the value here is at least the second use, thus proving the
# caching worthwhile.
if context.cached_param_result_used:
# This represents a saved call to `parameterizer.parameterize`
metrics.incr("grouping.cached_param_result_used")

context.cached_param_result_used = True
else:
parameterized = context.parameterizer.parameterize(message)

message_parameterized = parameterized != message
# Before we mark the parameterizer as having been used, check if it's already marked that
# way. If so, that means our use of it here is at least the second use, thus proving the
# caching worthwhile.
if context.cached_parameterizer_used:
# This represents a saved call to `in_rollout_group` on the project vis-à-vis
# experimental parameterization
metrics.incr("grouping.cached_parameterizer_used")

context.cached_parameterizer_used = True

if message_parameterized:
metrics.incr("grouping.message_parameterized", tags={"source": reason})
metrics.incr("grouping.message_used", tags={"reason": reason})

return _trim_extra_lines(parameterized) if trim_message else parameterized

Expand Down
Loading