Example project: Logs to trace example
Step 1: Prerequisites
- API key with access to your workspace
- Environment variables:
KEYWORDSAI_API_KEY
KEYWORDSAI_BASE_URL
Step 2: Understand the payload
Send an array of JSON objects, each representing a span (log item). Spans with the sametrace_unique_id
are grouped into a single trace. Parent-child relationships are inferred via span_parent_id
.
Key fields:
trace_unique_id
(string, required) — groups spans into a single tracespan_unique_id
(string, required) — unique ID for the spanspan_parent_id
(string, optional) — omit or setnull
for root spansspan_name
(string, optional) — e.g., “openai.chat”, “workflow.start”span_workflow_name
(string, optional) — nearest parent workflow name (not a top-level grouping field)span_path
(string, optional) — nested path within the workflowstart_time
(RFC3339 UTC, optional)timestamp
(RFC3339 UTC, optional)provider_id
,model
,input
,output
,metadata
,keywordsai_params
, etc. (optional)
Step 3: Make the request
- Endpoint:
{KEYWORDSAI_BASE_URL}/v1/traces/ingest
- Authentication:
Authorization: Bearer ${KEYWORDSAI_API_KEY}
Payload overview
Send an array of JSON objects. Each object represents a span (log item) that will be assembled into one or more traces. Field definitions (to be confirmed):- trace_unique_id: string — groups spans into a single trace. Required
- span_unique_id: string — unique ID for the span. Required
- span_parent_id: string — parent span’s unique ID; omit or set null for root. Optional
- span_name: string — name of the span (e.g., “openai.chat”). Optional
- span_workflow_name: string — name of the workflow or top-level process. Optional
- span_path: string — nested function/path of the workflow. Optional
- timestamp: ISO 8601 / RFC3339 (UTC) — event/end time. Required?
- start_time: ISO 8601 / RFC3339 (UTC) — start time. Required?
- input/output: string or JSON. Optional
- provider_id: string — e.g., “openai”. Optional
- latency: number (seconds). Optional
- metadata: object — custom attributes. Optional
- keywordsai_params: object — additional Keywords AI params. Optional
- Spans with the same
trace_unique_id
will be grouped into a single trace. - Hierarchy is inferred from
span_parent_id
relationships. - Timestamps should be in UTC using a Z suffix or timezone offset.
- Span IDs should be unique across a trace; avoid collisions with existing traces. TBD
- Maximum payload size, rate limits, and ordering requirements. TBD