Skip to content

Commit c617bb5

Browse files
jan-auerandrewshie-sentry
authored andcommitted
fix(spans): Align hrs key in the span buffer (#93230)
The `hrs` key includes the entire span's set key, which already includes the partition number as sharding key. With this, it is not necessary to double-encode the partition. This also re-aligns the lua script with cleanup in the buffer.
1 parent 02a01ba commit c617bb5

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/sentry/scripts/spans/add-buffer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ end
4141
local set_key = string.format("span-buf:s:{%s}:%s:%s", partition, project_and_trace, set_span_id)
4242
local parent_key = string.format("span-buf:s:{%s}:%s:%s", partition, project_and_trace, parent_span_id)
4343

44-
local has_root_span_key = string.format("span-buf:hrs:{%s}:%s", partition, set_key)
44+
local has_root_span_key = string.format("span-buf:hrs:%s", set_key)
4545
has_root_span = has_root_span or redis.call("get", has_root_span_key) == "1"
4646
if has_root_span then
4747
redis.call("setex", has_root_span_key, set_timeout, "1")

src/sentry/spans/buffer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,7 @@ def done_flush_segments(self, segment_keys: dict[SegmentKey, FlushedSegment]):
477477
with metrics.timer("spans.buffer.done_flush_segments"):
478478
with self.client.pipeline(transaction=False) as p:
479479
for segment_key, flushed_segment in segment_keys.items():
480-
hrs_key = b"span-buf:hrs:" + segment_key
481-
p.delete(hrs_key)
480+
p.delete(b"span-buf:hrs:" + segment_key)
482481
p.unlink(segment_key)
483482
p.zrem(flushed_segment.queue_key, segment_key)
484483

0 commit comments

Comments
 (0)