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(grouping): Add sample rate for grouphash metadata backfill #85127

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add should_handle_grouphash_metadata helper
  • Loading branch information
lobsterkatie committed Feb 13, 2025
commit 46d0d1c1e580fe5166f93b17bb9f906939f5d7ad
18 changes: 18 additions & 0 deletions src/sentry/grouping/ingest/grouphash_metadata.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import annotations

import logging
import random
from typing import Any, TypeIs, cast

from sentry import features, options
from sentry.eventstore.models import Event
from sentry.grouping.api import get_contributing_variant_and_component
from sentry.grouping.component import (
Expand Down Expand Up @@ -95,6 +97,22 @@
}


def should_handle_grouphash_metadata(project: Project, grouphash_is_new: bool) -> bool:
# Killswitches
if not options.get("grouping.grouphash_metadata.ingestion_writes_enabled") or not features.has(
"organizations:grouphash-metadata-creation", project.organization
):
return False

# While we're backfilling metadata for existing grouphash records, if the load is too high, we
# want to prioritize metadata for new grouphashes because there's certain information
# (timestamp, Seer data) which is only available at group creation time.
if grouphash_is_new:
return True
else:
return random.random() <= options.get("grouping.grouphash_metadata.backfill_sample_rate")


def create_or_update_grouphash_metadata_if_needed(
event: Event,
project: Project,
Expand Down