trace_span.py 1.2 KB

123456789101112131415161718192021222324
  1. from datetime import datetime
  2. from core_db import AuditMixin, Base, EntityMixin
  3. from core_shared import JSONValue
  4. from sqlalchemy import DateTime, Integer, String, Text
  5. from sqlalchemy import JSON
  6. from sqlalchemy.orm import Mapped, mapped_column
  7. class TraceSpan(EntityMixin, AuditMixin, Base):
  8. __tablename__ = "trace_span"
  9. run_id: Mapped[str] = mapped_column(String(36), index=True)
  10. node_run_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
  11. parent_span_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
  12. span_type: Mapped[str] = mapped_column(String(64), index=True)
  13. name: Mapped[str] = mapped_column(String(128))
  14. status: Mapped[str] = mapped_column(String(32), default="running", index=True)
  15. started_time: Mapped[datetime] = mapped_column(DateTime)
  16. ended_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
  17. duration_ms: Mapped[int | None] = mapped_column(Integer, nullable=True)
  18. attributes_json: Mapped[dict[str, JSONValue] | None] = mapped_column(JSON, nullable=True)
  19. error_code: Mapped[str | None] = mapped_column(String(64), nullable=True)
  20. error_message: Mapped[str | None] = mapped_column(Text, nullable=True)