Skip to main content

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

AttributeTypeDescriptionRequiredExample
gen_ai.session.idStringSession IDNo"ddde34343-f93a-4477-33333-sdfsdaf"
gen_ai.user.idStringApplication user IDNo"e1b330b0-d177-4dce-9407-f18ff7f9d600" or "tingyun"
gen_ai.span.kindStringOperation type detailYes"LLM"
gen_ai.frameworkStringFramework typeNo"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

AttributeTypeDescriptionRequiredExample
gen_ai.span.kindStringOperation typeYes"WORKFLOW"
gen_ai.frameworkStringApplication frameworkYes"dify"
gen_ai.session.idStringSession IDNo"ddde34343-f93a-4477-33333-sdfsdaf"
gen_ai.user.idStringApplication user IDNo"e1b330b0-d177-4dce-9407-f18ff7f9d600" or "tingyun"
gen_ai.workflow.total_stepsStringNumber of nodes in WORKFLOWNo"12"
gen_ai.workflow.node_typeStringNode type in WORKFLOWNo"llm"
gen_ai.workflow.indexStringNode index in WORKFLOWNo"6"
gen_ai.statusStringFinal execution statusNo"success"
gen_ai.titleStringCustom nameNo"AI Assistant"
gen_ai.errorStringOriginal error messageNo"Failed to invoke model, Range of input length should be [1, 14000]"}!"
gen_ai.input_textStringAPI request content, usually JSON, with length limitNo"Who Are You!"
gen_ai.process_dataStringAPI request processed data, with length limitNo"Hello, Who Are You!"
gen_ai.output_textStringAPI response content, usually JSON, with length limitNo"I am ChatBot"
gen_ai.usage.input_tokensStringNumber of tokens in promptNo"100"
gen_ai.usage.output_tokensStringNumber of tokens in completionNo"200"
gen_ai.usage.total_tokensStringTotal number of tokens, including prompt and completionNo"300"

LLM & AGENT

AttributeTypeDescriptionRequiredExample
gen_ai.span.kindStringOperation typeYes"LLM" or "AGENT"
gen_ai.frameworkStringApplication frameworkYes"dify"
gen_ai.systemStringLLM providerYes"OPENAI"
gen_ai.streamStringWhether response is in stream formatNo"True"
gen_ai.session.idStringSession IDNo"ddde34343-f93a-4477-33333-sdfsdaf"
gen_ai.operation.nameStringSecondary operation typeNo"chat" or "completion"
gen_ai.request.idStringRequest IDYes"ddde34343-f93a-4477-33333-sdfsdaf"
gen_ai.request.modelStringTarget LLM model nameYes"gpt-4"
gen_ai.request.stop_sequencesStringStop sequence stringsNo"stop"
gen_ai.request.frequency_penaltyStringFrequency penaltyNo"1.0"
gen_ai.request.presence_penaltyStringPresence penaltyNo"1.0"
gen_ai.request.repetition_penaltyStringRepetition penaltyNo"1.0"
gen_ai.request.max_tokensStringMax tokens to generateNo"8192"
gen_ai.request.seedStringRandom seedNo"1234"
gen_ai.request.temperatureStringLLM request temperatureNo"0.1"
gen_ai.request.top_kStringLLM request top_k settingNo"1"
gen_ai.request.top_pStringLLM request top_p settingNo"1"
gen_ai.request.response_formatStringLLM request response formatNo"json"
gen_ai.request.incremental_outputStringLLM request incremental outputNo"True"
gen_ai.response.idStringResponse IDNo"ddde34343-f93a-4477-33333-sdfsdaf"
gen_ai.response.modelStringLLM model name for responseYes"gpt-4"
gen_ai.response.finish_reasonStringModel stop reasonNo"stop"
gen_ai.workflow.node_typeStringNode type in WORKFLOWNo"llm"
gen_ai.workflow.indexStringNode index in WORKFLOWNo"6"
gen_ai.statusStringFinal status of LLM callNo"success"
gen_ai.titleStringCustom name for LLM callNo"AI Assistant"
gen_ai.errorStringOriginal error message from APINo"Failed to invoke model"
gen_ai.request.input_textStringAPI request content, usually JSON, with length limitNo"Who Are You!"
gen_ai.response.output_textStringAPI response content, usually JSON, with length limitNo"I am ChatBot"
gen_ai.usage.input_tokensStringNumber of tokens in promptNo"100"
gen_ai.usage.output_tokensStringNumber of tokens in completionNo"200"
gen_ai.usage.total_tokensStringTotal number of tokens, including prompt and completionNo"300"
gen_ai.response.first_pack_durationStringTime from LLM request to first response packet (for stream scenarios)No"10"