Skip to content

Commit

Permalink
feat(ddm): Implement bulk querying engine for metrics queries (#65066)
Browse files Browse the repository at this point in the history
  • Loading branch information
iambriccardo authored Feb 14, 2024
1 parent 1ba56fd commit 61ffcc4
Show file tree
Hide file tree
Showing 6 changed files with 339 additions and 262 deletions.
2 changes: 1 addition & 1 deletion src/sentry/api/endpoints/organization_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ def _metrics_queries_plan_from_request(self, request: Request) -> MetricsQueries
"""
Extracts the metrics queries plan from the request payload.
"""
# TODO: maybe we could use a serializer to read the body of the request.
metrics_queries_plan = MetricsQueriesPlan()

queries = request.data.get("queries") or []
Expand Down Expand Up @@ -406,7 +407,6 @@ def post(self, request: Request, organization) -> Response:
end=end,
interval=interval,
organization=organization,
# TODO: figure out how to make these methods work with HTTP body.
projects=self.get_projects(request, organization),
environments=self.get_environments(request, organization),
referrer=Referrer.API_DDM_METRICS_QUERY.value,
Expand Down
5 changes: 3 additions & 2 deletions src/sentry/sentry_metrics/querying/data_v2/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Sequence
from collections.abc import Mapping, Sequence
from datetime import datetime
from typing import Any

from snuba_sdk import MetricsQuery, MetricsScope, Rollup

Expand All @@ -22,7 +23,7 @@ def run_metrics_queries_plan(
projects: Sequence[Project],
environments: Sequence[Environment],
referrer: str,
):
) -> Mapping[str, Any]:
# For now, if the query plan is empty, we return an empty dictionary. In the future, we might want to default
# to a better data type.
if metrics_queries_plan.is_empty():
Expand Down
Loading

0 comments on commit 61ffcc4

Please sign in to comment.