@@ -64,6 +64,7 @@ def create_with_partitions(
64
64
committer = CommitOffsets (commit )
65
65
66
66
buffer = SpansBuffer (assigned_shards = [p .index for p in partitions ])
67
+ first_partition = next ((p .index for p in partitions ), 0 )
67
68
68
69
# patch onto self just for testing
69
70
flusher : ProcessingStrategy [FilteredPayload | int ]
@@ -75,7 +76,7 @@ def create_with_partitions(
75
76
76
77
if self .num_processes != 1 :
77
78
run_task = run_task_with_multiprocessing (
78
- function = partial (process_batch , buffer ),
79
+ function = partial (process_batch , buffer , first_partition ),
79
80
next_step = flusher ,
80
81
max_batch_size = self .max_batch_size ,
81
82
max_batch_time = self .max_batch_time ,
@@ -85,7 +86,7 @@ def create_with_partitions(
85
86
)
86
87
else :
87
88
run_task = RunTask (
88
- function = partial (process_batch , buffer ),
89
+ function = partial (process_batch , buffer , first_partition ),
89
90
next_step = flusher ,
90
91
)
91
92
@@ -119,7 +120,9 @@ def shutdown(self) -> None:
119
120
120
121
121
122
def process_batch (
122
- buffer : SpansBuffer , values : Message [ValuesBatch [tuple [int , KafkaPayload ]]]
123
+ buffer : SpansBuffer ,
124
+ first_partition : int ,
125
+ values : Message [ValuesBatch [tuple [int , KafkaPayload ]]],
123
126
) -> int :
124
127
min_timestamp = None
125
128
spans = []
@@ -130,10 +133,9 @@ def process_batch(
130
133
131
134
val = rapidjson .loads (payload .value )
132
135
133
- partition_id : int | None = None
134
-
136
+ partition_id : int = first_partition
135
137
if len (value .committable ) == 1 :
136
- partition_id = value . committable [ next (iter (value .committable ))]
138
+ partition_id = next (iter (value .committable )). index
137
139
138
140
if killswitches .killswitch_matches_context (
139
141
"spans.drop-in-buffer" ,
@@ -147,7 +149,7 @@ def process_batch(
147
149
continue
148
150
149
151
span = Span (
150
- partition = partition_id if partition_id is not None else - 1 , # TODO: Fallback OK?
152
+ partition = partition_id ,
151
153
trace_id = val ["trace_id" ],
152
154
span_id = val ["span_id" ],
153
155
parent_span_id = val .get ("parent_span_id" ),
0 commit comments