-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(event-search): event-tags/heatmap api #13350
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
Changes from all commits
b557bb3
96d49f9
93c0b49
a835f9a
4ae9ab3
f3d6236
027e885
0dc2680
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,9 @@ | |
|
||
from rest_framework.response import Response | ||
|
||
from sentry import tagstore | ||
from sentry.api.bases import OrganizationEventsEndpointBase, OrganizationEventsError, NoProjects | ||
from sentry.api.exceptions import ResourceDoesNotExist | ||
from sentry.api.helpers.events import get_direct_hit_response | ||
from sentry.api.paginator import GenericOffsetPaginator | ||
from sentry.api.serializers import EventSerializer, serialize, SimpleEventSerializer | ||
|
@@ -137,6 +139,41 @@ def get(self, request, organization): | |
) | ||
|
||
|
||
class OrganizationEventsHeatmapEndpoint(OrganizationEventsEndpointBase): | ||
def get(self, request, organization): | ||
try: | ||
snuba_args = self.get_snuba_query_args(request, organization) | ||
except OrganizationEventsError as exc: | ||
return Response({'detail': exc.message}, status=400) | ||
except NoProjects: | ||
return Response({'detail': 'A valid project must be included.'}, status=400) | ||
|
||
lookup_keys = [tagstore.prefix_reserved_key(key) for key in request.GET.getlist('keys')] | ||
|
||
if not lookup_keys: | ||
return Response({'detail': 'Tag keys must be specified.'}, status=400) | ||
project_ids = snuba_args['filter_keys']['project_id'] | ||
environment_ids = snuba_args['filter_keys'].get('environment_id') | ||
|
||
has_global_views = features.has( | ||
'organizations:global-views', | ||
organization, | ||
actor=request.user) | ||
|
||
if not has_global_views and len(project_ids) > 1: | ||
return Response({ | ||
'detail': 'You cannot view events from multiple projects.' | ||
}, status=400) | ||
|
||
try: | ||
tag_key = tagstore.get_group_tag_keys_and_top_values( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you mentioned when we were discussing this yesterday. I didn't notice at the time that this has the word |
||
project_ids, None, environment_ids, keys=lookup_keys, get_excluded_tags=True, **snuba_args) | ||
except tagstore.TagKeyNotFound: | ||
raise ResourceDoesNotExist | ||
|
||
return Response(serialize(tag_key, request.user)) | ||
|
||
|
||
class OrganizationEventsMetaEndpoint(OrganizationEventsEndpointBase): | ||
|
||
def get(self, request, organization): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also ensure that orgs without
global-views
don't do multi-project queries here too? Like in #13365