Skip to content

Commit 6cd40b6

Browse files
committed
fix(trace-explorer): Date range narrowing condition is backwards
This was changing the end timestamp to be too narrow and missing some spans.
1 parent 435669b commit 6cd40b6

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
@@ -356,12 +356,17 @@ def get_traces_matching_metric_conditions(
356356
return min_timestamp, max_timestamp, [], []
357357
else:
358358
# No user queries so take the first N trace ids as our list
359+
min_timestamp = snuba_params.end
360+
max_timestamp = snuba_params.start
361+
assert min_timestamp is not None
362+
assert max_timestamp is not None
363+
359364
trace_ids = trace_ids[: self.limit]
360365
timestamps = timestamps[: self.limit]
361366
for timestamp in timestamps:
362367
if timestamp < min_timestamp:
363368
min_timestamp = timestamp
364-
if timestamp < max_timestamp:
369+
if timestamp > max_timestamp:
365370
max_timestamp = timestamp
366371

367372
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)