Skip to content

Commit 99c748b

Browse files
authored
fix(trace): Remove spans from meta response (#94983)
- This removes the spans data from the meta response - To make transistion easier we're just keeping the keys but having them return empty or 0
1 parent 0ad18c8 commit 99c748b

File tree

2 files changed

+14
-40
lines changed

2 files changed

+14
-40
lines changed

src/sentry/api/endpoints/organization_events_trace.py

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,16 +1767,6 @@ def get(self, request: Request, organization: Organization, trace_id: str) -> Ht
17671767
query=f"trace:{trace_id}",
17681768
limit=1,
17691769
)
1770-
span_meta_query = SpansIndexedQueryBuilder(
1771-
dataset=Dataset.SpansIndexed,
1772-
selected_columns=[
1773-
"count() as span_count",
1774-
],
1775-
params={},
1776-
snuba_params=snuba_params,
1777-
query=f"trace:{trace_id}",
1778-
limit=1,
1779-
)
17801770
transaction_children_query = SpansIndexedQueryBuilder(
17811771
dataset=Dataset.SpansIndexed,
17821772
selected_columns=[
@@ -1789,35 +1779,19 @@ def get(self, request: Request, organization: Organization, trace_id: str) -> Ht
17891779
query=f"trace:{trace_id}",
17901780
limit=10_000,
17911781
)
1792-
span_count_query = SpansIndexedQueryBuilder(
1793-
dataset=Dataset.SpansIndexed,
1794-
selected_columns=[
1795-
"span.op",
1796-
"count()",
1797-
],
1798-
orderby=["-count()"],
1799-
params={},
1800-
snuba_params=snuba_params,
1801-
query=f"trace:{trace_id}",
1802-
limit=10_000,
1803-
)
18041782

18051783
with handle_query_errors():
18061784
results = bulk_snuba_queries(
18071785
[
18081786
meta_query.get_snql_query(),
18091787
transaction_children_query.get_snql_query(),
1810-
span_meta_query.get_snql_query(),
1811-
span_count_query.get_snql_query(),
18121788
],
18131789
referrer=Referrer.API_TRACE_VIEW_GET_META.value,
18141790
query_source=query_source,
18151791
)
1816-
meta_result, children_result, span_meta_result, span_count_result = (
1792+
meta_result, children_result = (
18171793
results[0],
18181794
results[1],
1819-
results[2],
1820-
results[3],
18211795
)
18221796
if len(meta_result["data"]) == 0:
18231797
return Response(status=404)
@@ -1831,21 +1805,21 @@ def get(self, request: Request, organization: Organization, trace_id: str) -> Ht
18311805
self.serialize(
18321806
meta_result["data"][0],
18331807
children_result["data"],
1834-
span_count_result["data"],
1835-
span_meta_result["data"][0],
18361808
)
18371809
)
18381810

18391811
def serialize(
1840-
self, results: Mapping[str, int], child_result: Any, span_result: Any, span_meta_result: Any
1812+
self,
1813+
results: Mapping[str, int],
1814+
child_result: Any,
18411815
) -> Mapping[str, int | dict[str, int]]:
18421816
return {
18431817
# Values can be null if there's no result
18441818
"projects": results.get("projects") or 0,
18451819
"transactions": results.get("transactions") or 0,
18461820
"errors": results.get("errors") or 0,
18471821
"performance_issues": results.get("performance_issues") or 0,
1848-
"span_count": span_meta_result.get("span_count") or 0,
1822+
"span_count": 0,
18491823
"transaction_child_count_map": child_result,
1850-
"span_count_map": {row["span.op"]: row["count"] for row in span_result},
1824+
"span_count_map": {},
18511825
}

tests/snuba/api/endpoints/test_organization_events_trace.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,8 +1708,8 @@ def test_simple(self):
17081708
assert data["transactions"] == 8
17091709
assert data["errors"] == 0
17101710
assert data["performance_issues"] == 2
1711-
assert data["span_count"] == 19
1712-
assert data["span_count_map"]["http.server"] == 19
1711+
assert data["span_count"] == 0
1712+
assert data["span_count_map"] == {}
17131713

17141714
def test_no_team(self):
17151715
self.load_trace()
@@ -1725,8 +1725,8 @@ def test_no_team(self):
17251725
assert data["transactions"] == 8
17261726
assert data["errors"] == 0
17271727
assert data["performance_issues"] == 2
1728-
assert data["span_count"] == 19
1729-
assert data["span_count_map"]["http.server"] == 19
1728+
assert data["span_count"] == 0
1729+
assert data["span_count_map"] == {}
17301730

17311731
def test_with_errors(self):
17321732
self.load_trace()
@@ -1743,8 +1743,8 @@ def test_with_errors(self):
17431743
assert data["transactions"] == 8
17441744
assert data["errors"] == 3
17451745
assert data["performance_issues"] == 2
1746-
assert data["span_count"] == 19
1747-
assert data["span_count_map"]["http.server"] == 19
1746+
assert data["span_count"] == 0
1747+
assert data["span_count_map"] == {}
17481748

17491749
def test_with_default(self):
17501750
self.load_trace()
@@ -1761,6 +1761,6 @@ def test_with_default(self):
17611761
assert data["transactions"] == 8
17621762
assert data["errors"] == 1
17631763
assert data["performance_issues"] == 2
1764-
assert data["span_count"] == 19
1765-
assert data["span_count_map"]["http.server"] == 19
1764+
assert data["span_count"] == 0
1765+
assert data["span_count_map"] == {}
17661766
assert len(data["transaction_child_count_map"]) == 8

0 commit comments

Comments
 (0)