SpanData

class opik.api_objects.span.SpanData(trace_id: str, id: str = <factory>, parent_span_id: str | None = None, type: Literal['general', 'tool', 'llm', 'guardrail']='general', usage: Dict[str, ~typing.Any] | ~opik.llm_usage.opik_usage.OpikUsage | None=None, model: str | None = None, provider: LLMProvider | str | None = None, total_cost: float | None = None, *, name: str | None = None, start_time: datetime | None = <factory>, end_time: datetime | None = None, metadata: Dict[str, ~typing.Any] | None=None, input: Dict[str, ~typing.Any] | None=None, output: Dict[str, ~typing.Any] | None=None, tags: List[str] | None = None, feedback_scores: List[FeedbackScoreDict] | None = None, project_name: str | None = None, error_info: ErrorInfoDict | None = None, attachments: List[Attachment] | None = None, source: Literal['sdk', 'experiment', 'optimization']='sdk', environment: str | None = None)

Bases: ObservationData

The SpanData object is returned when calling opik.opik_context.get_current_span_data() from a tracked function.

trace_id: str
id: str
parent_span_id: str | None = None
type: Literal['general', 'tool', 'llm', 'guardrail'] = 'general'
usage: Dict[str, Any] | OpikUsage | None = None
model: str | None = None
provider: LLMProvider | str | None = None
total_cost: float | None = None
create_child_span_data(name: str | None = None, type: Literal['general', 'tool', 'llm', 'guardrail'] = 'general', start_time: datetime | None = None, end_time: datetime | None = None, metadata: Dict[str, Any] | None = None, input: Dict[str, Any] | None = None, output: Dict[str, Any] | None = None, tags: List[str] | None = None, usage: Dict[str, Any] | OpikUsage | None = None, feedback_scores: List[FeedbackScoreDict] | None = None, model: str | None = None, provider: LLMProvider | str | None = None, error_info: ErrorInfoDict | None = None, total_cost: float | None = None, attachments: List[Attachment] | None = None) SpanData
property as_start_parameters: Dict[str, Any]

Returns parameters of this span to be sent to the server when starting a new span.

property as_parameters: Dict[str, Any]

Returns all parameters of this span to be sent to the server.

get_distributed_trace_headers() DistributedTraceHeadersDict