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

feat(CapMan): Replays queries now have tenant_ids #45885

Merged
merged 5 commits into from
Mar 16, 2023
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
2 changes: 2 additions & 0 deletions src/sentry/eventstore/snuba/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def get_event_by_id(self, project_id, event_id, group_id=None):
filter_keys={"project_id": [project_id], "event_id": [event_id]},
limit=1,
referrer="eventstore.get_event_by_id_nodestore",
tenant_ids={"organization_id": event.project.organization_id},
**raw_query_kwargs,
)
except snuba.QueryOutsideRetentionError:
Expand Down Expand Up @@ -338,6 +339,7 @@ def __get_event_id_from_filter(
referrer="eventstore.get_next_or_prev_event_id",
orderby=orderby,
dataset=dataset,
tenant_ids=tenant_ids,
)
except (snuba.QueryOutsideRetentionError, snuba.QueryOutsideGroupActivityError):
# This can happen when the date conditions for paging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def get(self, request: Request, organization: Organization) -> Response:
start=snuba_params.start,
end=snuba_params.end,
replay_ids=list(replay_ids_mapping.keys()),
tenant_ids={"organization_id": organization.id},
)

if request.GET.get("returnIds"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def data_fn(offset, limit):
limit=limit,
offset=offset,
search_filters=search_filters,
tenant_ids={"organization_id": organization.id},
)

return self.paginate(
Expand Down
1 change: 1 addition & 0 deletions src/sentry/replays/endpoints/project_replay_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def get(self, request: Request, project: Project, replay_id: str) -> Response:
replay_id=replay_id,
start=filter_params["start"],
end=filter_params["end"],
tenant_ids={"organization_id": project.organization_id},
)

response = process_raw_response(
Expand Down
10 changes: 10 additions & 0 deletions src/sentry/replays/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def query_replays_collection(
limit: Optional[str],
offset: Optional[str],
search_filters: List[SearchFilter],
tenant_ids: dict[str, Any],
) -> dict:
"""Query aggregated replay collection."""
conditions = []
Expand All @@ -75,6 +76,7 @@ def query_replays_collection(
sorting=sort_ordering,
pagination=paginators,
search_filters=search_filters,
tenant_ids=tenant_ids,
)
return response["data"]

Expand All @@ -84,6 +86,7 @@ def query_replay_instance(
replay_id: str,
start: datetime,
end: datetime,
tenant_ids: dict[str, Any],
):
"""Query aggregated replay instance."""
response = query_replays_dataset(
Expand All @@ -98,6 +101,7 @@ def query_replay_instance(
sorting=[],
pagination=None,
search_filters=[],
tenant_ids=tenant_ids,
)
return response["data"]

Expand All @@ -112,6 +116,7 @@ def query_replays_dataset(
sorting: List[OrderBy],
pagination: Optional[Paginators],
search_filters: List[SearchFilter],
tenant_ids: dict[str, Any],
):
query_options = {}

Expand Down Expand Up @@ -158,6 +163,7 @@ def query_replays_dataset(
granularity=Granularity(3600),
**query_options,
),
tenant_ids=tenant_ids,
)
return raw_snql_query(snuba_request, "replays.query.query_replays_dataset")

Expand All @@ -167,6 +173,7 @@ def query_replays_count(
start: datetime,
end: datetime,
replay_ids: List[str],
tenant_ids: dict[str, Any],
):

snuba_request = Request(
Expand Down Expand Up @@ -198,6 +205,7 @@ def query_replays_count(
groupby=[Column("replay_id")],
granularity=Granularity(3600),
),
tenant_ids=tenant_ids,
)
return raw_snql_query(
snuba_request, referrer="replays.query.query_replays_count", use_cache=True
Expand All @@ -210,6 +218,7 @@ def query_replays_dataset_tagkey_values(
end: datetime,
environment: str | None,
tag_key: str,
tenant_ids: dict[str, Any] | None,
):
"""Query replay tagkey values. Like our other tag functionality, aggregates do not work here."""

Expand Down Expand Up @@ -256,6 +265,7 @@ def query_replays_dataset_tagkey_values(
groupby=[grouped_column],
granularity=Granularity(3600),
limit=Limit(1000),
tenant_ids=tenant_ids,
),
)
return raw_snql_query(
Expand Down
1 change: 1 addition & 0 deletions src/sentry/tagstore/snuba/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,7 @@ def get_tag_value_paginator_for_projects(
end=end,
environment=filters.get("environment"),
tag_key=key,
tenant_ids=tenant_ids,
)
results = {
d["tag_value"]: {
Expand Down