Skip to content

feat(events): Use SnubaEvent if option is turned on #12594

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

Merged
merged 3 commits into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 8 additions & 2 deletions src/sentry/api/endpoints/event_file_committers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

from rest_framework.response import Response

from sentry import options
from sentry.api.bases.project import ProjectEndpoint
from sentry.models import Commit, Event, Release
from sentry.models import Commit, Event, SnubaEvent, Release
from sentry.utils.committers import get_event_file_committers


Expand All @@ -21,7 +22,12 @@ def get(self, request, project, event_id):
retrieve (as reported by the raven client).
:auth: required
"""
event = Event.objects.from_event_id(event_id, project.id)

use_snuba = options.get('snuba.events-queries.enabled')

event_cls = event_cls = SnubaEvent if use_snuba else Event

event = event_cls.objects.from_event_id(event_id, project.id)
if event is None:
return Response({'detail': 'Event not found'}, status=404)

Expand Down
10 changes: 8 additions & 2 deletions src/sentry/api/endpoints/event_grouping_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

from django.http import HttpResponse

from sentry import options
from sentry.api.bases.project import ProjectEndpoint
from sentry.api.exceptions import ResourceDoesNotExist
from sentry.grouping.api import ConfigNotFoundException
from sentry.models import Event
from sentry.models import Event, SnubaEvent
from sentry.utils import json


Expand All @@ -20,7 +21,12 @@ def get(self, request, project, event_id):
This endpoint returns a JSON dump of the metadata that went into the
grouping algorithm.
"""
event = Event.objects.from_event_id(event_id, project_id=project.id)

use_snuba = options.get('snuba.events-queries.enabled')

event_cls = event_cls = SnubaEvent if use_snuba else Event

event = event_cls.objects.from_event_id(event_id, project_id=project.id)
if event is None:
raise ResourceDoesNotExist

Expand Down
9 changes: 7 additions & 2 deletions src/sentry/api/endpoints/event_owners.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

from rest_framework.response import Response

from sentry import options
from sentry.api.bases.project import ProjectEndpoint
from sentry.api.fields.actor import Actor
from sentry.api.serializers import serialize
from sentry.api.serializers.models.actor import ActorSerializer
from sentry.models import Event, ProjectOwnership
from sentry.models import Event, SnubaEvent, ProjectOwnership


class EventOwnersEndpoint(ProjectEndpoint):
Expand All @@ -21,7 +22,11 @@ def get(self, request, project, event_id):
:auth: required
"""

event = Event.objects.from_event_id(event_id, project.id)
use_snuba = options.get('snuba.events-queries.enabled')

event_cls = SnubaEvent if use_snuba else Event

event = event_cls.objects.from_event_id(event_id, project.id)
Copy link
Member

Choose a reason for hiding this comment

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

Would it be outlandish to make Event.objects.from_event_id do this logic internally? That might help you play fewer rounds of whac-a-mole.

if event is None:
return Response({'detail': 'Event not found'}, status=404)

Expand Down