"""Span types for distributed tracing."""

from enum import StrEnum
from typing import Any

from pydantic import BaseModel


class SpanKind(StrEnum):
    RUN = "run"
    PATHWAY = "pathway"
    NODE = "node"
    TOOL = "tool"
    LLM = "llm"


class SpanStatus(StrEnum):
    OK = "ok"
    ERROR = "error"


class Span(BaseModel):
    """A minimal, JSON-friendly span record."""

    model_config = {"frozen": True}

    span_id: str
    run_id: str
    parent_span_id: str | None
    kind: SpanKind
    name: str
    start_ms: int
    end_ms: int | None = None
    status: SpanStatus = SpanStatus.OK
    error: str | None = None
    attributes: dict[str, Any] | None = None
    inputs: dict[str, Any] | None = None
    outputs: dict[str, Any] | None = None


__all__ = [
    "Span",
    "SpanKind",
    "SpanStatus",
]
