Skip to content

Commit a2e264b

Browse files
cvxluoandrewshie-sentry
authored andcommitted
ref(api): clean up global-views from events API (#98684)
Clean up `global-views` check in `get_snuba_params` since `global-views` (cross-project selection) is now available for all plans.
1 parent 0ec3a68 commit a2e264b

18 files changed

+15
-141
lines changed

src/sentry/api/bases/organization_events.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ def get_snuba_params(
133133
self,
134134
request: Request,
135135
organization: Organization,
136-
check_global_views: bool = True,
137136
quantize_date_params: bool = True,
138137
) -> SnubaParams:
139138
"""Returns params to make snuba queries with"""
@@ -171,15 +170,6 @@ def get_snuba_params(
171170
sampling_mode=sampling_mode,
172171
debug=request.user.is_superuser and "debug" in request.GET,
173172
)
174-
175-
if check_global_views:
176-
has_global_views = features.has(
177-
"organizations:global-views", organization, actor=request.user
178-
)
179-
fetching_replay_data = request.headers.get("X-Sentry-Replay-Request") == "1"
180-
if not has_global_views and len(params.projects) > 1 and not fetching_replay_data:
181-
raise ParseError(detail="You cannot view events from multiple projects.")
182-
183173
return params
184174

185175
def get_orderby(self, request: Request) -> list[str] | None:
@@ -539,9 +529,7 @@ def get_event_stats_data(
539529
if snuba_params is None:
540530
try:
541531
# events-stats is still used by events v1 which doesn't require global views
542-
snuba_params = self.get_snuba_params(
543-
request, organization, check_global_views=False
544-
)
532+
snuba_params = self.get_snuba_params(request, organization)
545533
except NoProjects:
546534
return {"data": []}
547535

src/sentry/api/endpoints/organization_events.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,6 @@ def get(self, request: Request, organization: Organization) -> Response:
250250
snuba_params = self.get_snuba_params(
251251
request,
252252
organization,
253-
# This is only temporary until we come to a decision on global views
254-
# checking for referrer for an allowlist is a brittle check since referrer
255-
# can easily be set by the caller
256-
check_global_views=not (
257-
referrer in GLOBAL_VIEW_ALLOWLIST and bool(organization.flags.allow_joinleave)
258-
),
259253
)
260254
except NoProjects:
261255
return Response(

src/sentry/api/endpoints/organization_events_has_measurements.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ def get(self, request: Request, organization: Organization) -> Response:
6161

6262
with sentry_sdk.start_span(op="discover.endpoint", name="parse params"):
6363
try:
64-
# This endpoint only allows for a single project + transaction, so no need
65-
# to check `global-views`.
66-
snuba_params = self.get_snuba_params(
67-
request, organization, check_global_views=False
68-
)
64+
snuba_params = self.get_snuba_params(request, organization)
6965

7066
# Once an transaction begins containing measurement data, it is unlikely
7167
# it will stop. So it makes more sense to always query the latest data.

src/sentry/api/endpoints/organization_events_meta.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ class OrganizationEventsRelatedIssuesEndpoint(OrganizationEventsEndpointBase):
128128

129129
def get(self, request: Request, organization: Organization) -> Response:
130130
try:
131-
# events-meta is still used by events v1 which doesn't require global views
132-
snuba_params = self.get_snuba_params(request, organization, check_global_views=False)
131+
snuba_params = self.get_snuba_params(request, organization)
133132
except NoProjects:
134133
return Response([])
135134

src/sentry/api/endpoints/organization_events_spans_performance.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,11 @@ def get_snuba_params(
9191
self,
9292
request: Request,
9393
organization: Organization,
94-
check_global_views: bool = True,
9594
quantize_date_params: bool = True,
9695
) -> SnubaParams:
9796
snuba_params = super().get_snuba_params(
9897
request,
9998
organization,
100-
check_global_views=check_global_views,
10199
quantize_date_params=quantize_date_params,
102100
)
103101

src/sentry/api/endpoints/organization_events_timeseries.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,8 @@ def get(self, request: Request, organization: Organization) -> Response:
164164
sentry_sdk.set_tag("performance.metrics_enhanced", metrics_enhanced)
165165
try:
166166
snuba_params = self.get_snuba_params(
167-
# old events-stats had global_check on False for v1, trying it off to see if that works for our
168-
# new usage
169167
request,
170168
organization,
171-
check_global_views=True,
172169
)
173170
except NoProjects:
174171
return Response([], status=200)

src/sentry/api/endpoints/organization_events_trace.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,7 @@ def get(self, request: Request, organization: Organization, trace_id: str) -> Ht
844844
return Response(status=404)
845845

846846
try:
847-
# The trace view isn't useful without global views, so skipping the check here
848-
snuba_params = self.get_snuba_params(request, organization, check_global_views=False)
847+
snuba_params = self.get_snuba_params(request, organization)
849848
except NoProjects:
850849
return Response(status=404)
851850

@@ -1024,9 +1023,7 @@ def serialize(
10241023
current_generation = 0
10251024
break
10261025

1027-
snuba_params = self.get_snuba_params(
1028-
self.request, self.request.organization, check_global_views=False
1029-
)
1026+
snuba_params = self.get_snuba_params(self.request, self.request.organization)
10301027
if current_generation is None:
10311028
for root in roots:
10321029
# We might not be necessarily connected to the root if we're on an orphan event
@@ -1178,9 +1175,7 @@ def serialize(
11781175
parent_events: dict[str, TraceEvent] = {}
11791176
results_map: dict[str | None, list[TraceEvent]] = defaultdict(list)
11801177
to_check: Deque[SnubaTransaction] = deque()
1181-
snuba_params = self.get_snuba_params(
1182-
self.request, self.request.organization, check_global_views=False
1183-
)
1178+
snuba_params = self.get_snuba_params(self.request, self.request.organization)
11841179
# The root of the orphan tree we're currently navigating through
11851180
orphan_root: SnubaTransaction | None = None
11861181
if roots:
@@ -1484,8 +1479,7 @@ def get(self, request: Request, organization: Organization, trace_id: str) -> Ht
14841479
return Response(status=404)
14851480

14861481
try:
1487-
# The trace meta isn't useful without global views, so skipping the check here
1488-
snuba_params = self.get_snuba_params(request, organization, check_global_views=False)
1482+
snuba_params = self.get_snuba_params(request, organization)
14891483
except NoProjects:
14901484
return Response(status=404)
14911485

src/sentry/api/endpoints/organization_metrics_meta.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ def get(self, request: Request, organization: Organization) -> Response:
3131
"compatible_projects": [],
3232
}
3333
try:
34-
# This will be used on the perf homepage and contains preset queries, allow global views
35-
snuba_params = self.get_snuba_params(request, organization, check_global_views=False)
34+
snuba_params = self.get_snuba_params(request, organization)
3635
except NoProjects:
3736
return Response(data)
3837
original_project_ids = snuba_params.project_ids[:]
@@ -84,8 +83,7 @@ def get(self, request: Request, organization: Organization) -> Response:
8483
},
8584
}
8685
try:
87-
# This will be used on the perf homepage and contains preset queries, allow global views
88-
snuba_params = self.get_snuba_params(request, organization, check_global_views=False)
86+
snuba_params = self.get_snuba_params(request, organization)
8987
except NoProjects:
9088
return Response(data)
9189

src/sentry/api/endpoints/organization_tagkey_values.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ def get(self, request: Request, organization, key) -> Response:
4848
sentry_sdk.set_tag("dataset", Dataset.Events.value)
4949

5050
try:
51-
# still used by events v1 which doesn't require global views
52-
snuba_params = self.get_snuba_params(request, organization, check_global_views=False)
51+
snuba_params = self.get_snuba_params(request, organization)
5352
except NoProjects:
5453
paginator: SequencePaginator[TagValue] = SequencePaginator([])
5554
else:

src/sentry/api/endpoints/organization_trace.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ def get(self, request: Request, organization: Organization, trace_id: str) -> Ht
7171
return Response(status=404)
7272

7373
try:
74-
# The trace view isn't useful without global views, so skipping the check here
75-
snuba_params = self.get_snuba_params(request, organization, check_global_views=False)
74+
snuba_params = self.get_snuba_params(request, organization)
7675
except NoProjects:
7776
return Response(status=404)
7877

0 commit comments

Comments
 (0)