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

ref(seer grouping): Add platform to did_call_seer metric #80965

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
37 changes: 7 additions & 30 deletions src/sentry/grouping/ingest/seer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
filter_null_from_string,
get_stacktrace_string,
killswitch_enabled,
record_did_call_seer_metric,
)
from sentry.utils import metrics
from sentry.utils.circuit_breaker2 import CircuitBreaker
Expand Down Expand Up @@ -90,22 +91,14 @@ def _has_customized_fingerprint(event: Event, variants: dict[str, BaseVariant])

# Hybrid fingerprinting ({{ default }} + some other value(s))
else:
metrics.incr(
"grouping.similarity.did_call_seer",
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"call_made": False, "blocker": "hybrid-fingerprint"},
)
record_did_call_seer_metric(event, called=False, blocker="hybrid-fingerprint")
return True

# Fully customized fingerprint (from either us or the user)
fingerprint_variant = variants.get("custom_fingerprint") or variants.get("built_in_fingerprint")

if fingerprint_variant:
metrics.incr(
"grouping.similarity.did_call_seer",
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"call_made": False, "blocker": fingerprint_variant.type},
)
record_did_call_seer_metric(event, called=False, blocker=fingerprint_variant.type)
return True

return False
Expand All @@ -128,11 +121,7 @@ def _ratelimiting_enabled(event: Event, project: Project) -> bool:
logger_extra["limit_per_sec"] = global_limit_per_sec
logger.warning("should_call_seer_for_grouping.global_ratelimit_hit", extra=logger_extra)

metrics.incr(
"grouping.similarity.did_call_seer",
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"call_made": False, "blocker": "global-rate-limit"},
)
record_did_call_seer_metric(event, called=False, blocker="global-rate-limit")

return True

Expand All @@ -142,11 +131,7 @@ def _ratelimiting_enabled(event: Event, project: Project) -> bool:
logger_extra["limit_per_sec"] = project_limit_per_sec
logger.warning("should_call_seer_for_grouping.project_ratelimit_hit", extra=logger_extra)

metrics.incr(
"grouping.similarity.did_call_seer",
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"call_made": False, "blocker": "project-rate-limit"},
)
record_did_call_seer_metric(event, called=False, blocker="project-rate-limit")

return True

Expand All @@ -167,11 +152,7 @@ def _circuit_breaker_broken(event: Event, project: Project) -> bool:
**breaker_config,
},
)
metrics.incr(
"grouping.similarity.did_call_seer",
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"call_made": False, "blocker": "circuit-breaker"},
)
record_did_call_seer_metric(event, called=False, blocker="circuit-breaker")

return circuit_broken

Expand Down Expand Up @@ -236,11 +217,7 @@ def maybe_check_seer_for_matching_grouphash(
seer_matched_grouphash = None

if should_call_seer_for_grouping(event, variants):
metrics.incr(
"grouping.similarity.did_call_seer",
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"call_made": True, "blocker": "none"},
)
record_did_call_seer_metric(event, called=True, blocker="none")

try:
# If no matching group is found in Seer, we'll still get back result
Expand Down
32 changes: 17 additions & 15 deletions src/sentry/seer/similarity/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,23 +345,20 @@ def killswitch_enabled(project_id: int, event: Event | None = None) -> bool:
"should_call_seer_for_grouping.seer_global_killswitch_enabled",
extra=logger_extra,
)
metrics.incr(
"grouping.similarity.did_call_seer",
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"call_made": False, "blocker": "global-killswitch"},
)
# `event` will be defined when we're calling this from ingest, which is really what the
# `did_call_seer` is meant to track
if event:
record_did_call_seer_metric(event, called=False, blocker="global-killswitch")

return True

if options.get("seer.similarity-killswitch.enabled"):
logger.warning(
"should_call_seer_for_grouping.seer_similarity_killswitch_enabled",
extra=logger_extra,
)
metrics.incr(
"grouping.similarity.did_call_seer",
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"call_made": False, "blocker": "similarity-killswitch"},
)
if event:
record_did_call_seer_metric(event, called=False, blocker="similarity-killswitch")
return True

if killswitch_matches_context(
Expand All @@ -371,11 +368,8 @@ def killswitch_enabled(project_id: int, event: Event | None = None) -> bool:
"should_call_seer_for_grouping.seer_similarity_project_killswitch_enabled",
extra=logger_extra,
)
metrics.incr(
"grouping.similarity.did_call_seer",
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"call_made": False, "blocker": "project-killswitch"},
)
if event:
record_did_call_seer_metric(event, called=False, blocker="project-killswitch")
return True

return False
Expand Down Expand Up @@ -421,3 +415,11 @@ def project_is_seer_eligible(project: Project) -> bool:
is_region_enabled = options.get("similarity.new_project_seer_grouping.enabled")

return not is_backfill_completed and is_seer_eligible_platform and is_region_enabled


def record_did_call_seer_metric(event: Event, called: bool, blocker: str) -> None:
metrics.incr(
"grouping.similarity.did_call_seer",
sample_rate=options.get("seer.similarity.metrics_sample_rate"),
tags={"call_made": called, "blocker": blocker, "platform": event.platform},
Copy link
Member

Choose a reason for hiding this comment

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

since event.platform can be None, should we make it unknown if it's None?

)
Loading