File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed
src/openlayer/lib/tracing Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -518,15 +518,13 @@ def __next__(self):
518518 func_kwargs = func_kwargs ,
519519 context_kwarg = context_kwarg ,
520520 )
521- # Capture context after trace is initialized for ASGI compatibility
522- # This ensures we can finalize in the correct context even if
523- # later __next__ calls happen in different worker threads
524- self ._captured_context = contextvars .copy_context ()
525521 self ._trace_initialized = True
526522
527523 try :
528524 chunk = next (self ._original_gen )
529525 self ._output_chunks .append (chunk )
526+ if self ._captured_context is None :
527+ self ._captured_context = contextvars .copy_context ()
530528 return chunk
531529 except StopIteration :
532530 # Finalize trace when generator is exhausted
You can’t perform that action at this time.
0 commit comments