|
95 | 95 | import sentry_sdk |
96 | 96 | from django.conf import settings |
97 | 97 | from django.db import router |
| 98 | +from django.utils import timezone |
98 | 99 |
|
99 | 100 | from sentry import models, nodestore, options |
100 | 101 | from sentry.attachments import CachedAttachment, attachment_cache, store_attachments_for_event |
|
104 | 105 | from sentry.models.project import Project |
105 | 106 | from sentry.objectstore import get_attachments_session |
106 | 107 | from sentry.options.rollout import in_random_rollout |
| 108 | +from sentry.search.eap.occurrences.common_queries import count_occurrences |
| 109 | +from sentry.search.eap.occurrences.rollout_utils import EAPOccurrencesComparator |
107 | 110 | from sentry.services import eventstore |
108 | 111 | from sentry.services.eventstore.models import Event, GroupEvent |
109 | 112 | from sentry.services.eventstore.processing import event_processing_store |
110 | 113 | from sentry.services.eventstore.reprocessing import reprocessing_store |
111 | 114 | from sentry.snuba.dataset import Dataset |
| 115 | +from sentry.snuba.occurrences_rpc import OccurrenceCategory |
| 116 | +from sentry.snuba.referrer import Referrer |
112 | 117 | from sentry.types.activity import ActivityType |
113 | 118 | from sentry.utils import metrics, snuba |
114 | 119 | from sentry.utils.cache import cache_key_for_event |
@@ -573,6 +578,9 @@ def start_group_reprocessing( |
573 | 578 |
|
574 | 579 | with transaction.atomic(router.db_for_write(models.Group)): |
575 | 580 | group = models.Group.objects.get(id=group_id) |
| 581 | + project = group.project |
| 582 | + organization = project.organization |
| 583 | + group_first_seen = group.first_seen |
576 | 584 | original_status = group.status |
577 | 585 | original_substatus = group.substatus |
578 | 586 | if original_status == models.GroupStatus.REPROCESSING: |
@@ -628,14 +636,45 @@ def start_group_reprocessing( |
628 | 636 | for model in GROUP_MODELS_TO_MIGRATE: |
629 | 637 | model.objects.filter(group_id=group_id).update(group_id=new_group.id) |
630 | 638 |
|
631 | | - # Get event counts of issue (for all environments etc). This was copypasted |
| 639 | + # Get event counts of issue (for all environments etc). This was copy-pasted |
632 | 640 | # and simplified from groupserializer. |
633 | | - event_count = sync_count = snuba.aliased_query( |
| 641 | + referrer = Referrer.REPROCESSING2_START_GROUP_REPROCESSING.value |
| 642 | + snuba_count = snuba.aliased_query( |
634 | 643 | aggregations=[["count()", "", "times_seen"]], # select |
635 | 644 | dataset=Dataset.Events, # from |
636 | 645 | conditions=[["group_id", "=", group_id], ["project_id", "=", project_id]], # where |
637 | | - referrer="reprocessing2.start_group_reprocessing", |
| 646 | + referrer=referrer, |
638 | 647 | )["data"][0]["times_seen"] |
| 648 | + event_count = sync_count = snuba_count |
| 649 | + |
| 650 | + callsite = "reprocessing2.start_group_reprocessing" |
| 651 | + if EAPOccurrencesComparator.should_check_experiment(callsite): |
| 652 | + count_end = timezone.now() |
| 653 | + eap_count = count_occurrences( |
| 654 | + organization=organization, |
| 655 | + projects=[project], |
| 656 | + start=group_first_seen, |
| 657 | + end=count_end, |
| 658 | + referrer=referrer, |
| 659 | + group_id=group_id, |
| 660 | + occurrence_category=OccurrenceCategory.ERROR, |
| 661 | + ) |
| 662 | + event_count = sync_count = EAPOccurrencesComparator.check_and_choose( |
| 663 | + control_data=snuba_count, |
| 664 | + experimental_data=eap_count, |
| 665 | + callsite=callsite, |
| 666 | + is_experimental_data_a_null_result=eap_count == 0, |
| 667 | + reasonable_match_comparator=lambda snuba, eap: eap <= snuba, |
| 668 | + debug_context={ |
| 669 | + "organization_id": organization.id, |
| 670 | + "project_id": project.id, |
| 671 | + "group_id": group_id, |
| 672 | + "group_first_seen": ( |
| 673 | + group_first_seen.isoformat() if group_first_seen is not None else None |
| 674 | + ), |
| 675 | + "count_end": count_end.isoformat(), |
| 676 | + }, |
| 677 | + ) |
639 | 678 |
|
640 | 679 | sentry_sdk.set_extra("event_count", event_count) |
641 | 680 |
|
|
0 commit comments