mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 12:16:20 +00:00
Write chat traces off the stream's thread
The OTel replay and the trace INSERT ran in the stream's finally, so a slow database held the SSE connection open after the last event. The trace is still frozen when the stream ends, but written on a small writer pool.
This commit is contained in:
1 parent
0591580014
commit
778830208b
7 files changed
+91
-19
No files matched your search
@@ -110,7 +110,9 @@ def _traced_stream(
|
||||
try:
|
||||
yield from method(*bound.args, **bound.kwargs)
|
||||
finally:
|
||||
tracing.flush(trace)
|
||||
# Written on a writer thread so the stream's connection closes
|
||||
# without waiting on the OTel replay and the INSERT.
|
||||
tracing.flush(trace, background=True)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
Reference in new issue
Block a user