# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel


class Span(UniversalBaseModel):
    data: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Any additional metadata or context for the span
    """

    end_time: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    The time the span ended
    """

    id: str
    input: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Input parameters or data for the operation
    """

    name: str = pydantic.Field()
    """
    Name that describes what operation this span represents
    """

    output: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Output data resulting from the operation
    """

    parent_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    ID of the parent span if this is a child span in a trace
    """

    start_time: dt.datetime = pydantic.Field()
    """
    The time the span started
    """

    task_id: str = pydantic.Field()
    """
    ID of the task this span is associated with, used for authorization
    """

    trace_id: str = pydantic.Field()
    """
    Unique identifier for the trace this span belongs to
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
