Create Log Span
Create an individual log span that can be associated with an existing trace.
Header
All requests require a valid workspace API key passed in the Authorization
header:
Parameters
The unique identifier of the project.
The span object containing span details.
The ID of an existing trace (required if traceReferenceId not provided).
The reference ID of an existing trace (required if traceId not provided).
The unique identifier of the prompt used.
The deployment ID used for this span.
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 stringified JSON content of the span (max 1MB).
Whether to run evaluation on this span.
Reference ID of the parent span.
External reference ID for the span.
Session ID associated with the span.
Additional attributes for the span.
Array of tags for categorization.
Array of events that occurred during the span.
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.