Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.langsight.dev/llms.txt

Use this file to discover all available pages before exploring further.

POST /api/traces/spans

Accepts ToolCallSpan objects from the LangSight Python SDK.
curl -X POST http://localhost:8000/api/traces/spans \
  -H "Content-Type: application/json" \
  -d '[{
    "server_name": "postgres-mcp",
    "tool_name": "query",
    "started_at": "2026-03-17T12:00:00Z",
    "ended_at": "2026-03-17T12:00:00.042Z",
    "latency_ms": 42.0,
    "status": "success",
    "trace_id": "trace-abc123",
    "agent_name": "support-agent",
    "session_id": "sess-xyz",
    "span_type": "tool_call",
    "input_args": {"query": "SELECT * FROM orders WHERE id = $1", "params": [42]},
    "output_result": "[{\"id\": 42, \"status\": \"shipped\"}]",
    "project_id": "proj-abc"
  }]'
Response: {"accepted": 1} with HTTP 202.

ToolCallSpan fields

FieldTypeRequiredDescription
server_namestringYesTool server name, agent name, or "handoff"
tool_namestringYesTool called, agent task description, or target agent name
started_atISO datetimeYesWhen the span began (UTC)
ended_atISO datetimeYesWhen the span completed (UTC)
latency_msfloatYesDuration in milliseconds
statussuccess | error | timeoutYesOutcome of the span
span_idstringUUID (auto-generated if omitted)
parent_span_idstringspan_id of the parent span — enables multi-agent tree reconstruction
span_typetool_call | agent | handoffSpan kind (defaults to tool_call)
trace_idstringGroups all spans for one task or conversation
session_idstringApplication-level session identifier
agent_namestringWhich agent emitted this span
project_idstringProject this span belongs to
errorstringError message when status is error or timeout
input_argsobjectArguments passed to the tool call. null when redact_payloads=true
output_resultstringTool return value serialised to JSON string. null when redacted or on error
llm_inputstringLLM prompt or messages (agent spans only, from OTLP gen_ai.prompt)
llm_outputstringLLM completion text (agent spans only)
input_tokensintegerLLM input token count (from OTLP gen_ai.usage.input_tokens)
output_tokensintegerLLM output token count (from OTLP gen_ai.usage.output_tokens)
model_idstringModel used for this span (from OTLP gen_ai.request.model)

Field population by span type

Not all fields are meaningful for every span type. This table shows which fields are populated in practice:
Fieldtool_callagenthandoff
server_nameMCP server / API nameagent namefrom-agent name
tool_nametool calledtask description"→ <target-agent>"
agent_nameagent that made the callsame as server_namefrom-agent name
parent_span_idparent agent or handoff spanparent span if nestedparent agent span
input_argstool arguments (if not redacted)
output_resulttool return value (if not redacted)
llm_inputLLM prompt text
llm_outputLLM completion text
input_tokenstoken count for this agent turn
output_tokenstoken count for this agent turn
model_idmodel used by this agent

Multi-agent span tree example

trace_id: "trace-123"
├── span: agent    / server_name=support-agent  / parent_span_id=null
│   ├── span: tool_call / server_name=jira-mcp / tool_name=get_issue   / parent=agent-span
│   ├── span: handoff   / server_name=support-agent / tool_name="→ billing-agent" / parent=agent-span
│   │   ├── span: tool_call / server_name=crm-mcp  / tool_name=update_customer / parent=handoff-span
│   │   └── span: tool_call / server_name=slack-mcp / tool_name=post_message   / parent=handoff-span
trace_id groups the entire task. parent_span_id reconstructs the tree. Both fields are set by the SDK automatically when using the LangSightTracer context manager.

POST /api/traces/otlp

Accepts standard OTLP/JSON trace data from any OpenTelemetry-instrumented framework.
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:8000/api/traces/otlp
LangSight extracts spans by matching:
  • Span names matching mcp.*
  • Attribute gen_ai.tool.name (GenAI semantic conventions)
  • Attribute mcp.server.name + mcp.tool.name
The following OTLP attributes are mapped to ToolCallSpan fields:
OTLP attributeToolCallSpan field
gen_ai.promptllm_input
gen_ai.completionllm_output
gen_ai.usage.input_tokensinput_tokens
gen_ai.usage.output_tokensoutput_tokens
gen_ai.request.modelmodel_id
Non-matching spans are ignored.