Log Span
This API allows you to create an individual log span that can be associated with an existing trace.
Request
Header
Bearer Token Authentication
All API requests must include a valid workspace API key in the Authorization header using the Bearer token format.
You can create your workspace API key in Adaline by visiting Settings > API Keys.
Body
The unique identifier of the project.
The span object containing span details.
Unix timestamp when the span started.
Unix timestamp when the span ended.
Name/identifier for the span.
Status of the span (one of: “success”, “failure”, “unknown”).
The content must be a valid JSON string with a type
field that determines the structure. Supported types include:
Model Type
For AI model interactions (LLM calls, completions, etc.):
Required Fields:
type
: String identifying the span typeprovider
: String identifying the provider of the modelmodel
: String identifying the modelinput
: JSON string containing input data, either exactly the payload sent to the LLM provider (using REST API) or using Adaline types.output
: JSON string containing output data, either exactly the response received from the LLM provider (using REST API) or using Adaline types.
If using Adaline types:
input.messages
: refer to MessageType.input.config
: refer to ConfigType.input.tools
: refer to ToolType.
If using Adaline types:
output.messages
: refer to MessageType.output.tokenUsage.promptTokens
: Number of tokens used for the prompt.output.tokenUsage.completionTokens
: Number of tokens used for the completion.output.tokenUsage.totalTokens
: Total number of tokens used.
If using LLM provider REST API payload, refer this example using OpenAI chat completion API payload:
Optional Fields:
cost
: Number representing the cost of the span (in USD)variables
: JSON object containing variable values.key
is the variable name andvalue
is the variable value of type ContentType.
Function Type
For function calls and executions:
Tool Type
For tool usage and API calls:
Guardrail Type
For safety and validation checks:
Retrieval Type
For document retrieval and search operations:
Embeddings Type
For text embedding operations:
Other Type
For custom span types not covered by the predefined categories:
Required Fields (for all span types other than ‘Model’):
type
: String identifying the span typeinput
: JSON string containing input dataoutput
: JSON string containing output data
Notes:
- Maximum content size is 1MB
The ID of an existing trace (required if traceReferenceId not provided).
The reference ID of an existing trace (required if traceId not provided). This is usually the traceId used within your application / system.
The unique identifier of the prompt used. If not provided, you will not be able to view the span in prompt’s monitor section.
The deployment ID used for this span.
Whether to run evaluation on this span.
Reference ID of the parent span. This is usually this span’s parent’s spanId used within your application / system.
External reference ID for the span. This is usually the spanId used within your application / system.
Session ID associated with the span. This is usually the sessionId / threadId / chatId used within your application / system.
Additional attributes for the span. Key-value pairs of attributes. Keys must be strings, values must be strings, numbers, or booleans.
Array of tags for categorization. Each tag must be a string.
Response
Array of unique identifiers for the created span.
Span Creation Validation Rules
- Trace Association: Either
traceId
ortraceReferenceId
must be provided - Time Validation:
startedAt
must be beforeendedAt
- Content Size: Content must not exceed 1MB when serialized to JSON
Best Practices
-
Structured Logging: Use consistent naming conventions for traces and spans to enable better analysis.
-
Reference IDs: Use meaningful reference IDs that can be tracked across your application for better debugging.
-
Content Size Management: Monitor your content size to stay within the 1MB limit per span.
-
Batch Operations: When possible, use the trace endpoint to create multiple spans in a single request.
-
Time Accuracy: Ensure timestamps are accurate and represent the actual start/end times of operations.
-
Meaningful Attributes: Use attributes and tags to add context that will be useful for analysis and debugging.
-
Session Tracking: Use session IDs consistently to track user sessions across multiple traces.