Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def get(self, request: Request, organization: Organization) -> Response:
return Response(status=404)

query = request.GET.get("query")
span_ops = request.GET.getlist("spanOp")

direction, orderby_column = self.get_orderby_column(request)

Expand All @@ -75,7 +76,7 @@ def data_fn(offset: int, limit: int) -> Any:
SPAN_PERFORMANCE_COLUMNS[orderby_column].suspect_op_group_column
)
orderby = direction + alias
suspects = query_suspect_span_groups(params, query, orderby, limit, offset)
suspects = query_suspect_span_groups(params, query, span_ops, orderby, limit, offset)

alias = get_function_alias(
SPAN_PERFORMANCE_COLUMNS[orderby_column].suspect_example_column
Expand Down Expand Up @@ -115,8 +116,6 @@ def data_fn(offset: int, limit: int) -> Any:
max_per_page=4,
)

return Response(status=200)

def get_orderby_column(self, request: Request) -> Tuple[str, str]:
orderbys = super().get_orderby(request)

Expand Down Expand Up @@ -219,6 +218,7 @@ def serialize(self) -> Any:
def query_suspect_span_groups(
params: ParamsType,
query: Optional[str],
span_ops: Optional[List[str]],
order_column: str,
limit: int,
offset: int,
Expand All @@ -244,6 +244,17 @@ def query_suspect_span_groups(
functions_acl=["array_join", "sumArray", "percentileArray", "maxArray"],
)

if span_ops:
builder.add_conditions(
[
Condition(
builder.resolve_function("array_join(spans_op)"),
Op.IN,
Function("tuple", span_ops),
),
]
)

snql_query = builder.get_snql_query()
results = raw_snql_query(snql_query, "api.organization-events-spans-performance-suspects")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,29 @@ def test_sort_percentiles(self):
],
)

@pytest.mark.skip("setting snuba config is too slow")
def test_op_filters(self):
event = self.create_event()

with self.feature(self.FEATURES):
response = self.client.get(
self.url,
data={
"project": self.project.id,
"sort": "-count",
"spanOp": "http.server",
},
format="json",
)

assert response.status_code == 200, response.content
self.assert_suspect_span(
response.data,
# when sorting by -count, this should be the last of the 3 results
# but the spanOp filter means it should be the only result
[self.suspect_span_results("percentiles", event)],
)

@pytest.mark.skip("setting snuba config is too slow")
def test_pagination_first_page(self):
self.create_event()
Expand Down