Alternatively, instrument your app with Axiom AI SDK. For more information on instrumentation approaches, see Introduction to Observe.
Required attributes
Axiom’s conventions for AI spans are based on version 1.37 of the OpenTelemetry semantic conventions for generative client AI spans. Axiom requires the following attributes in your data to properly recognize your spans:gen_ai.operation.name
identifies AI spans. It’s also a required attribute in the OpenTelemetry specification.gen_ai.capability.name
provides context about the specific capability being used within the AI operation.gen_ai.step.name
allows you to break down the AI operation into individual steps for more granular tracking.
gen_ai.operation.name
Axiom currently provides custom UI for the following operations related to the gen_ai.operation.name
attribute:
chat
: Chat completionexecute_tool
: Tool execution
generate_content
: Multimodal content generationembeddings
: Vector embeddingscreate_agent
: Create AI agentsinvoke_agent
: Invoke existing agentstext_completion
: Text completion. This is a legacy value and has been deprecated by OpenAI and many other providers.
Recommended attributes
Axiom recommends the following attributes to get the most out of Axiom’s AI telemetry features:axiom.gen_ai
attributes
axiom.gen_ai.schema_url
: Schema URL for the Axiom AI conventions. For example:https://axiom.co/ai/schemas/0.0.2
axiom.gen_ai.sdk.name
: Name of the SDK. For example:my-ai-instrumentation-sdk
axiom.gen_ai.sdk.version
: Version of the SDK. For example:1.2.3
Chat spans
Attribute | Type | Required | Description |
---|---|---|---|
gen_ai.provider.name | string | Required | Provider (openai, anthropic, aws.bedrock, etc.) |
gen_ai.request.model | string | When available | Model requested (gpt-4, claude-3, etc.) |
gen_ai.response.model | string | When available | Model that fulfilled the request |
gen_ai.input.messages | Messages[] (stringified) | Recommended | Input conversation history |
gen_ai.output.messages | Messages[] (stringified) | Recommended | Model response messages |
gen_ai.usage.input_tokens | integer | Recommended | Input token count |
gen_ai.usage.output_tokens | integer | Recommended | Output token count |
gen_ai.request.choice_count | integer | When >1 | Number of completion choices requested |
gen_ai.response.id | string | Recommended | Unique response identifier |
gen_ai.response.finish_reasons | string[] | Recommended | Why generation stopped |
gen_ai.conversation.id | string | When available | Conversation/session identifier |
Tool spans
For tool operations (execute_tool
), include these additional attributes:
Attribute | Type | Required | Description |
---|---|---|---|
gen_ai.tool.name | string | Required | Name of the executed tool |
gen_ai.tool.call.id | string | When available | Tool call identifier |
gen_ai.tool.type | string | When available | Tool type (function, extension, datastore) |
gen_ai.tool.description | string | When available | Tool description |
gen_ai.tool.arguments | string | When available | Tool arguments |
gen_ai.tool.message | string | When available | Tool message |
Agent spans
For agent operations (create_agent
, invoke_agent
), include these additional attributes:
Attribute | Type | Required | Description |
---|---|---|---|
gen_ai.agent.id | string | When available | Unique agent identifier |
gen_ai.agent.name | string | When available | Human-readable agent name |
gen_ai.agent.description | string | When available | Agent description/purpose |
gen_ai.conversation.id | string | When available | Conversation/session identifier |
Span naming
Ensure span names follow the OpenTelemetry conventions for generative AI spans. For example, the suggested span names for common values ofgen_ai.operation.name
are the following:
chat {gen_ai.request.model}
execute_tool {gen_ai.tool.name}
embeddings {gen_ai.request.model}
generate_content {gen_ai.request.model}
text_completion {gen_ai.request.model}
create_agent {gen_ai.agent.name}
invoke_agent {gen_ai.agent.name}
Messages
Messages support four different roles, each with specific content formats. They follow OpenTelemetry’s structured format:System messages
System messages are messages that the system adds to set the behavior of the assistant. They typically contain instructions or context for the AI model.User messages
User messages are messages that users send to the AI model. They typically contain questions, commands, or other input from the user.Assistant messages
Assistant messages are messages that the AI model sends back to the user. They typically contain responses, answers, or other output from the model.Tool messages
Tool messages are messages that contain the results of tool calls made by the AI model. They typically contain the output or response from the tool.Content part types
text
: Text content withcontent
fieldtool_call
: Tool invocation withid
,name
,arguments
tool_call_response
: Tool result withid
,response
- Recording content on attributes
- JSON schema for inputs and outputs
Example trace structure
Chat completion
Example of a properly structured chat completion trace:Tool execution
Example of a tool execution within an agent:What’s next?
After sending traces with the proper semantic conventions:- View your traces in Console
- Set up monitors and alerts based on your AI telemetry data
- Learn about developing AI features with confidence using Axiom