Skip to content

Commit 4623b5d

Browse files
authored
fix(trace-explorer): Date range narrowing condition is backwards (#70496)
This was changing the end timestamp to be too narrow and missing some spans.
1 parent fc8b666 commit 4623b5d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/sentry/api/endpoints/organization_traces.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,17 @@ def get_traces_matching_metric_conditions(
357357
return min_timestamp, max_timestamp, [], []
358358
else:
359359
# No user queries so take the first N trace ids as our list
360+
min_timestamp = snuba_params.end
361+
max_timestamp = snuba_params.start
362+
assert min_timestamp is not None
363+
assert max_timestamp is not None
364+
360365
trace_ids = trace_ids[: self.limit]
361366
timestamps = timestamps[: self.limit]
362367
for timestamp in timestamps:
363368
if timestamp < min_timestamp:
364369
min_timestamp = timestamp
365-
if timestamp < max_timestamp:
370+
if timestamp > max_timestamp:
366371
max_timestamp = timestamp
367372

368373
self.refine_params(min_timestamp, max_timestamp)

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)