Skip to content

Commit 42b8a19

Browse files
authored
Merge pull request #1655 from weaviate/fix/otel-in-batch
Copy context to ensure open telemetry makes it to batch requests
2 parents 4f6a703 + 7e994f8 commit 42b8a19

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

weaviate/collections/batch/base.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import contextvars
2+
import functools
13
import math
24
import os
35
import threading
@@ -324,11 +326,15 @@ def __batch_send(self) -> None:
324326
uuid_lookup=self.__uuid_lookup,
325327
)
326328
# do not block the thread - the results are written to a central (locked) list and we want to have multiple concurrent batch-requests
329+
ctx = contextvars.copy_context()
327330
self.__executor.submit(
328-
self.__send_batch,
329-
objs,
330-
refs,
331-
readd_rate_limit=isinstance(self.__batching_mode, _RateLimitedBatching),
331+
ctx.run,
332+
functools.partial(
333+
self.__send_batch,
334+
objs,
335+
refs,
336+
readd_rate_limit=isinstance(self.__batching_mode, _RateLimitedBatching),
337+
),
332338
)
333339

334340
time.sleep(refresh_time)

0 commit comments

Comments
 (0)