GenAI Trace Field Definitions
LLM Trace fields are defined by TingYun with reference to the OpenTelemetry standard and concepts in the large language model (LLM) application domain. By extending Attributes, they are used to describe the semantics of LLM application call chain data, reflecting key operations such as LLM input/output requests and token consumption. They provide rich, context-related semantic data for scenarios such as Completion, Chat, RAG, Agent, and Tool, facilitating data tracing and reporting. These semantic fields will be continuously updated and optimized as the community evolves.
Attributes
General
| Attribute | Type | Description | Required | Example |
|---|---|---|---|---|
gen_ai.session.id | String | Session ID | No | "ddde34343-f93a-4477-33333-sdfsdaf" |
gen_ai.user.id | String | Application user ID | No | "e1b330b0-d177-4dce-9407-f18ff7f9d600" or "tingyun" |
gen_ai.span.kind | String | Operation type detail | Yes | "LLM" |
gen_ai.framework | String | Framework type | No | "dify" or "langchain" .. |
Span Kind
In practical LLM interaction scenarios, multiple operation steps are often involved. Based on the LLM application domain and development frameworks, the following operation types are currently defined. These types support extension, and different operation types have different Attributes fields.
- WORKFLOW: A tool that connects LLM and other components to accomplish complex tasks, possibly including Retrieval, Embedding, LLM calls, etc.
- LLM: Identifies calls to large models, such as reasoning or text generation via SDK or OpenAPI.
- AGENT: Intelligent agent scenario, a complex CHAIN that may involve multiple LLM and Tool calls, with step-by-step decision-making to reach the final answer.
WORKFLOW
| Attribute | Type | Description | Required | Example |
|---|---|---|---|---|
gen_ai.span.kind | String | Operation type | Yes | "WORKFLOW" |
gen_ai.framework | String | Application framework | Yes | "dify" |
gen_ai.session.id | String | Session ID | No | "ddde34343-f93a-4477-33333-sdfsdaf" |
gen_ai.user.id | String | Application user ID | No | "e1b330b0-d177-4dce-9407-f18ff7f9d600" or "tingyun" |
gen_ai.workflow.total_steps | String | Number of nodes in WORKFLOW | No | "12" |
gen_ai.workflow.node_type | String | Node type in WORKFLOW | No | "llm" |
gen_ai.workflow.index | String | Node index in WORKFLOW | No | "6" |
gen_ai.status | String | Final execution status | No | "success" |
gen_ai.title | String | Custom name | No | "AI Assistant" |
gen_ai.error | String | Original error message | No | "Failed to invoke model, Range of input length should be [1, 14000]"}!" |
gen_ai.input_text | String | API request content, usually JSON, with length limit | No | "Who Are You!" |
gen_ai.process_data | String | API request processed data, with length limit | No | "Hello, Who Are You!" |
gen_ai.output_text | String | API response content, usually JSON, with length limit | No | "I am ChatBot" |
gen_ai.usage.input_tokens | String | Number of tokens in prompt | No | "100" |
gen_ai.usage.output_tokens | String | Number of tokens in completion | No | "200" |
gen_ai.usage.total_tokens | String | Total number of tokens, including prompt and completion | No | "300" |
LLM & AGENT
| Attribute | Type | Description | Required | Example |
|---|---|---|---|---|
gen_ai.span.kind | String | Operation type | Yes | "LLM" or "AGENT" |
gen_ai.framework | String | Application framework | Yes | "dify" |
gen_ai.system | String | LLM provider | Yes | "OPENAI" |
gen_ai.stream | String | Whether response is in stream format | No | "True" |
gen_ai.session.id | String | Session ID | No | "ddde34343-f93a-4477-33333-sdfsdaf" |
gen_ai.operation.name | String | Secondary operation type | No | "chat" or "completion" |
gen_ai.request.id | String | Request ID | Yes | "ddde34343-f93a-4477-33333-sdfsdaf" |
gen_ai.request.model | String | Target LLM model name | Yes | "gpt-4" |
gen_ai.request.stop_sequences | String | Stop sequence strings | No | "stop" |
gen_ai.request.frequency_penalty | String | Frequency penalty | No | "1.0" |
gen_ai.request.presence_penalty | String | Presence penalty | No | "1.0" |
gen_ai.request.repetition_penalty | String | Repetition penalty | No | "1.0" |
gen_ai.request.max_tokens | String | Max tokens to generate | No | "8192" |
gen_ai.request.seed | String | Random seed | No | "1234" |
gen_ai.request.temperature | String | LLM request temperature | No | "0.1" |
gen_ai.request.top_k | String | LLM request top_k setting | No | "1" |
gen_ai.request.top_p | String | LLM request top_p setting | No | "1" |
gen_ai.request.response_format | String | LLM request response format | No | "json" |
gen_ai.request.incremental_output | String | LLM request incremental output | No | "True" |
gen_ai.response.id | String | Response ID | No | "ddde34343-f93a-4477-33333-sdfsdaf" |
gen_ai.response.model | String | LLM model name for response | Yes | "gpt-4" |
gen_ai.response.finish_reason | String | Model stop reason | No | "stop" |
gen_ai.workflow.node_type | String | Node type in WORKFLOW | No | "llm" |
gen_ai.workflow.index | String | Node index in WORKFLOW | No | "6" |
gen_ai.status | String | Final status of LLM call | No | "success" |
gen_ai.title | String | Custom name for LLM call | No | "AI Assistant" |
gen_ai.error | String | Original error message from API | No | "Failed to invoke model" |
gen_ai.request.input_text | String | API request content, usually JSON, with length limit | No | "Who Are You!" |
gen_ai.response.output_text | String | API response content, usually JSON, with length limit | No | "I am ChatBot" |
gen_ai.usage.input_tokens | String | Number of tokens in prompt | No | "100" |
gen_ai.usage.output_tokens | String | Number of tokens in completion | No | "200" |
gen_ai.usage.total_tokens | String | Total number of tokens, including prompt and completion | No | "300" |
gen_ai.response.first_pack_duration | String | Time from LLM request to first response packet (for stream scenarios) | No | "10" |