mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-15 22:14:46 +00:00
Store execution traces in a new request_traces table
One row per execution holding its span tree as JSONB, linked to Logs rows by request, message, activity and workflow-run ids. message_id cascades so deleting or truncating a conversation drops its traces; a daily beat task enforces TRACES_RETENTION_DAYS.
This commit is contained in:
1 parent
f6269c483f
commit
f3f817b1e8
7 files changed
+686
-10
No files matched your search
@@ -825,6 +825,42 @@ Index(
|
||||
Index("ix_guardrail_events_message", guardrail_events_table.c.message_id)
|
||||
Index("ix_guardrail_events_created", guardrail_events_table.c.created_at)
|
||||
|
||||
# One execution trace per request (chat turn, continuation, scheduled or
|
||||
# webhook run, search, graph extraction): the span tree as a JSONB array,
|
||||
# rendered as a waterfall in the Logs UI. ``message_id`` cascades so deleting
|
||||
# or truncating a conversation removes its traces. Migration 0037.
|
||||
request_traces_table = Table(
|
||||
"request_traces",
|
||||
metadata,
|
||||
Column("id", UUID(as_uuid=True), primary_key=True),
|
||||
Column("request_id", Text),
|
||||
Column(
|
||||
"message_id",
|
||||
UUID(as_uuid=True),
|
||||
ForeignKey("conversation_messages.id", ondelete="CASCADE"),
|
||||
),
|
||||
Column("conversation_id", UUID(as_uuid=True)),
|
||||
Column("activity_id", Text),
|
||||
Column("workflow_run_id", UUID(as_uuid=True)),
|
||||
Column("user_id", Text),
|
||||
Column("agent_id", UUID(as_uuid=True)),
|
||||
Column("source", Text, nullable=False),
|
||||
Column("name", Text),
|
||||
# ok | error | paused | cancelled
|
||||
Column("status", Text, nullable=False),
|
||||
Column("started_at", DateTime(timezone=True), nullable=False),
|
||||
Column("duration_ms", Integer, nullable=False, server_default="0"),
|
||||
Column("span_count", Integer, nullable=False, server_default="0"),
|
||||
Column("dropped_spans", Integer, nullable=False, server_default="0"),
|
||||
Column("summary", JSONB, nullable=False, server_default="{}"),
|
||||
Column("spans", JSONB, nullable=False, server_default="[]"),
|
||||
Column("otel_trace_id", Text),
|
||||
Column("created_at", DateTime(timezone=True), nullable=False, server_default=func.now()),
|
||||
)
|
||||
|
||||
Index("request_traces_user_started_idx", request_traces_table.c.user_id, request_traces_table.c.started_at)
|
||||
Index("request_traces_created_idx", request_traces_table.c.created_at)
|
||||
|
||||
tool_call_attempts_table = Table(
|
||||
"tool_call_attempts",
|
||||
metadata,
|
||||
|
||||
Reference in new issue
Block a user