Skip to content

Commit 97be5fd

Browse files
ZylphrexMichaelSun48
authored andcommitted
ref(trace-explorer): Bring trace id condition closer to query builder (#69312)
Having the trace id condition at the bottom makes for an unclear control flow. This brings to condition next to each query builder individually.
1 parent b2b8634 commit 97be5fd

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/sentry/api/endpoints/organization_traces.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,14 @@ def data_fn(offset: int, limit: int):
142142
all_projects_params["projects_objects"] = all_projects_snuba_params.projects
143143
all_projects_params["projects_id"] = all_projects_snuba_params.project_ids
144144

145+
trace_id_condition = Condition(Column("trace_id"), Op.IN, trace_ids)
146+
145147
with handle_query_errors():
146148
breakdowns_query = SpansIndexedQueryBuilder(
147149
Dataset.SpansIndexed,
148150
cast(ParamsType, all_projects_params),
149151
snuba_params=all_projects_snuba_params,
150-
query=None,
152+
query="is_transaction:1",
151153
selected_columns=[
152154
"trace",
153155
"project",
@@ -165,9 +167,7 @@ def data_fn(offset: int, limit: int):
165167
transform_alias_to_input_format=True,
166168
),
167169
)
168-
# TODO: this should be `is_transaction:1` but there's some
169-
# boolean mapping that's not working for this field
170-
breakdowns_query.add_conditions([Condition(Column("is_segment"), Op.EQ, 1)])
170+
breakdowns_query.add_conditions([trace_id_condition])
171171

172172
with handle_query_errors():
173173
traces_meta_query = SpansIndexedQueryBuilder(
@@ -188,6 +188,7 @@ def data_fn(offset: int, limit: int):
188188
transform_alias_to_input_format=True,
189189
),
190190
)
191+
traces_meta_query.add_conditions([trace_id_condition])
191192

192193
sort = serialized.get("sort")
193194
suggested_query = serialized.get("suggestedQuery", "")
@@ -213,17 +214,15 @@ def data_fn(offset: int, limit: int):
213214
)
214215
for query_str in query_strs
215216
]
217+
for spans_query in spans_queries:
218+
spans_query.add_conditions([trace_id_condition])
216219

217220
queries = [
218221
breakdowns_query,
219222
traces_meta_query,
220223
*spans_queries,
221224
]
222225

223-
trace_id_condition = Condition(Column("trace_id"), Op.IN, trace_ids)
224-
for query in queries:
225-
query.add_conditions([trace_id_condition])
226-
227226
with handle_query_errors():
228227
results = bulk_snql_query(
229228
[query.get_snql_query() for query in queries],

0 commit comments

Comments
 (0)