Skip to content

Commit 917eda2

Browse files
committed
fix(trace-explorer): Do not prematurely narrow date range
If we prematurely narrow the date range, there are some cases where a span isn't found in the results. So remove this attempted optimization.
1 parent 435669b commit 917eda2

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/sentry/api/endpoints/organization_traces.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,6 @@ def get_traces_matching_metric_conditions(
342342
if not trace_ids or min_timestamp > max_timestamp:
343343
return min_timestamp, max_timestamp, [], []
344344

345-
self.refine_params(min_timestamp, max_timestamp)
346-
347345
if self.user_queries:
348346
# If there are user queries, further refine the trace ids by applying them
349347
# leaving us with only traces where the metric exists and matches the user
@@ -356,16 +354,19 @@ def get_traces_matching_metric_conditions(
356354
return min_timestamp, max_timestamp, [], []
357355
else:
358356
# No user queries so take the first N trace ids as our list
357+
min_timestamp = snuba_params.end
358+
max_timestamp = snuba_params.start
359+
assert min_timestamp is not None
360+
assert max_timestamp is not None
361+
359362
trace_ids = trace_ids[: self.limit]
360363
timestamps = timestamps[: self.limit]
361364
for timestamp in timestamps:
362365
if timestamp < min_timestamp:
363366
min_timestamp = timestamp
364-
if timestamp < max_timestamp:
367+
if timestamp > max_timestamp:
365368
max_timestamp = timestamp
366369

367-
self.refine_params(min_timestamp, max_timestamp)
368-
369370
span_keys = executor.get_matching_spans_from_traces(
370371
trace_ids,
371372
self.max_spans_per_trace,

src/sentry/sentry_metrics/querying/samples_list.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def get_matching_spans_from_traces(
258258
# This also means we cannot order by any columns or paginate.
259259
orderby=None,
260260
limit=len(trace_ids) * max_spans_per_trace,
261-
limitby=("trace", 1),
261+
limitby=("trace", max_spans_per_trace),
262262
)
263263

264264
trace_id_condition = Condition(Column("trace_id"), Op.IN, trace_ids)
@@ -609,7 +609,7 @@ def get_matching_spans_from_traces(
609609
# This also means we cannot order by any columns or paginate.
610610
orderby=None,
611611
limit=len(trace_ids) * max_spans_per_trace,
612-
limitby=("trace", 1),
612+
limitby=("trace", max_spans_per_trace),
613613
)
614614

615615
trace_id_condition = Condition(Column("trace_id"), Op.IN, trace_ids)
@@ -943,7 +943,7 @@ def get_matching_spans_from_traces(
943943
# This also means we cannot order by any columns or paginate.
944944
orderby=None,
945945
limit=len(trace_ids) * max_spans_per_trace,
946-
limitby=("trace", 1),
946+
limitby=("trace", max_spans_per_trace),
947947
)
948948

949949
trace_id_condition = Condition(Column("trace_id"), Op.IN, trace_ids)

0 commit comments

Comments
 (0)