Documentation Index
Fetch the complete documentation index at: https://braintrust.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Summary
Issue: Traces for existing conversations using span.export() stop appearing in production logs after a server restart while new conversations continue to log correctly.
Cause: Exported span context is not persisted across restarts. Without it, the SDK creates an orphan span with no parent instead of continuing the existing trace.
Resolution: Persist exported span context to a durable store (e.g., a database) and reload it when needed to maintain trace continuity.
Resolution steps
Persist exported span context to maintain trace continuity
Step 1: Store exported span context in a durable location
Save the exported context to a database or persistent store after each operation.
exported_context = span.export()
# Store in database, Redis, or other persistent store
db.set(conversation_key, exported_context)
Step 2: Retrieve and use the context for subsequent operations
Load the stored context before creating new spans to maintain the trace relationship.
exported_context = db.get(conversation_key)
if exported_context:
span = bt.start_span(name="operation", parent=exported_context)
else:
span = bt.start_span(name="operation")
# Continue span logic before closing it and flushing
Step 3: Verify trace continuity
After implementing persistence, confirm that operations appearing after a restart continue under the existing trace rather than creating new orphaned traces.