Skip to content

Spans

Create a span
client.spans.create(SpanCreateParams { name, start_timestamp, trace_id, 14 more } body, RequestOptionsoptions?): Span { id, account_id, name, 19 more }
POST/v5/spans
Get a span
Deprecated
client.spans.retrieve(stringspanID, RequestOptionsoptions?): Span { id, account_id, name, 19 more }
GET/v5/spans/{span_id}
Update a span
client.spans.update(stringspanID, SpanUpdateParams { end_timestamp, metadata, name, 2 more } body, RequestOptionsoptions?): Span { id, account_id, name, 19 more }
PATCH/v5/spans/{span_id}
Create spans in a batch
client.spans.batch(SpanBatchParams { items } body, RequestOptionsoptions?): APIListSpan { items, object }
POST/v5/spans/batch
Upsert spans in a batch
client.spans.upsertBatch(SpanUpsertBatchParams { items } body, RequestOptionsoptions?): APIListSpan { items, object }
PUT/v5/spans/batch
Search spans
client.spans.search(SpanSearchParams { allow_short_pages, ending_before, from_ts, 29 more } params, RequestOptionsoptions?): CursorPage<Span { id, account_id, name, 19 more } >
POST/v5/spans/search
ModelsExpand Collapse
APIListSpan { items, object }
items: Array<Span { id, account_id, name, 19 more } >
id: string
account_id: string
name: string
start_timestamp: string
formatdate-time
trace_id: string

id for grouping traces together, uuid is recommended

maxLength256
application_interaction_id?: string

The interaction ID this span belongs to

application_variant_id?: string

The id of the application variant this span belongs to

created_by?: Identity { id, type, object }

The identity that created the entity.

id: string
type: "user" | "service_account"
One of the following:
"user"
"service_account"
object?: "identity"
end_timestamp?: string
formatdate-time
expected?: Record<string, unknown>
group_id?: string

Reference to a group_id

input?: Record<string, unknown>
input_tokens?: number

Prompt tokens the producer reported for this span, absent when it reported none. Same quantity the input_tokens sort orders by.

maximum4294967295
minimum0
metadata?: Record<string, unknown>
object?: "span"
obs_span_id?: string

W3C span id of the observability span this span executed in.

obs_trace_id?: string

W3C trace id of the observability trace this span executed in. Null for spans written without the edge, and for accounts still served by the legacy trace store.

output?: Record<string, unknown>
output_tokens?: number

Completion tokens the producer reported for this span, absent when it reported none. Same quantity the output_tokens sort orders by.

maximum4294967295
minimum0
parent_id?: string

Reference to a parent span_id

status?: SpanStatus
One of the following:
"SUCCESS"
"ERROR"
"CANCELED"
type?: SpanType
One of the following:
"TEXT_INPUT"
"TEXT_OUTPUT"
"COMPLETION_INPUT"
"COMPLETION"
"KB_RETRIEVAL"
"KB_INPUT"
"RERANKING"
"EXTERNAL_ENDPOINT"
"PROMPT_ENGINEERING"
"DOCUMENT_INPUT"
"MAP_REDUCE"
"DOCUMENT_SEARCH"
"DOCUMENT_PROMPT"
"CUSTOM"
"CODE_EXECUTION"
"DATA_MANIPULATION"
"EVALUATION"
"FILE_RETRIEVAL"
"KB_ADD_CHUNK"
"KB_MANAGEMENT"
"GUARDRAIL"
"OUTPUT_GUARDRAIL"
"TRACER"
"AGENT_TRACER"
"AGENT_WORKFLOW"
"STANDALONE"
object?: "list"
Span { id, account_id, name, 19 more }
id: string
account_id: string
name: string
start_timestamp: string
formatdate-time
trace_id: string

id for grouping traces together, uuid is recommended

maxLength256
application_interaction_id?: string

The interaction ID this span belongs to

application_variant_id?: string

The id of the application variant this span belongs to

created_by?: Identity { id, type, object }

The identity that created the entity.

id: string
type: "user" | "service_account"
One of the following:
"user"
"service_account"
object?: "identity"
end_timestamp?: string
formatdate-time
expected?: Record<string, unknown>
group_id?: string

Reference to a group_id

input?: Record<string, unknown>
input_tokens?: number

Prompt tokens the producer reported for this span, absent when it reported none. Same quantity the input_tokens sort orders by.

maximum4294967295
minimum0
metadata?: Record<string, unknown>
object?: "span"
obs_span_id?: string

W3C span id of the observability span this span executed in.

obs_trace_id?: string

W3C trace id of the observability trace this span executed in. Null for spans written without the edge, and for accounts still served by the legacy trace store.

output?: Record<string, unknown>
output_tokens?: number

Completion tokens the producer reported for this span, absent when it reported none. Same quantity the output_tokens sort orders by.

maximum4294967295
minimum0
parent_id?: string

Reference to a parent span_id

status?: SpanStatus
One of the following:
"SUCCESS"
"ERROR"
"CANCELED"
type?: SpanType
One of the following:
"TEXT_INPUT"
"TEXT_OUTPUT"
"COMPLETION_INPUT"
"COMPLETION"
"KB_RETRIEVAL"
"KB_INPUT"
"RERANKING"
"EXTERNAL_ENDPOINT"
"PROMPT_ENGINEERING"
"DOCUMENT_INPUT"
"MAP_REDUCE"
"DOCUMENT_SEARCH"
"DOCUMENT_PROMPT"
"CUSTOM"
"CODE_EXECUTION"
"DATA_MANIPULATION"
"EVALUATION"
"FILE_RETRIEVAL"
"KB_ADD_CHUNK"
"KB_MANAGEMENT"
"GUARDRAIL"
"OUTPUT_GUARDRAIL"
"TRACER"
"AGENT_TRACER"
"AGENT_WORKFLOW"
"STANDALONE"
SpanBatchCreate { items }
items: Array<SpanCreate { name, start_timestamp, trace_id, 14 more } >
name: string
start_timestamp: string

When the span started. With trace_id and id it forms the span’s storage identity, so a span re-sent with a start_timestamp on another UTC day is stored as a second row that the store never collapses. Get span and trace detail return the newest version. Search returns the newest version whose start_timestamp falls in the queried window. Export, metrics and facets count both rows until the trace is deleted and re-sent.

formatdate-time
trace_id: string

id for grouping traces together, uuid is recommended

maxLength256
id?: string

The id of the span, at most 256 bytes. A value longer than 256 characters is refused here with a 422 before it is forwarded; a value within that count whose UTF-8 form exceeds 256 bytes is refused with a 400 naming the field once the tracing service is the account’s primary store, and accepted for accounts still written primarily to the legacy trace store.

maxLength256
application_interaction_id?: string

The optional application interaction ID this span belongs to

application_variant_id?: string

The optional application variant ID this span belongs to

end_timestamp?: string
formatdate-time
expected?: Record<string, unknown>
group_id?: string

Reference to a group_id, at most 256 bytes. A value longer than 256 characters is refused here with a 422 before it is forwarded; a value within that count whose UTF-8 form exceeds 256 bytes is refused with a 400 naming the field once the tracing service is the account’s primary store, and accepted for accounts still written primarily to the legacy trace store.

maxLength256
input?: Record<string, unknown>
metadata?: Record<string, unknown>
obs_span_id?: string

W3C span id (16 lowercase hex chars) of the observability span this span executed in. Requires obs_trace_id.

obs_trace_id?: string

W3C trace id (32 lowercase hex chars) of the observability trace this span executed in, for correlating a business span with the infrastructure work it caused. Stored only by the sgp-traces service, so accounts still served by the legacy store accept the field and read it back as null.

output?: Record<string, unknown>
parent_id?: string

Reference to a parent span_id

status?: SpanStatus
One of the following:
"SUCCESS"
"ERROR"
"CANCELED"
type?: SpanType
One of the following:
"TEXT_INPUT"
"TEXT_OUTPUT"
"COMPLETION_INPUT"
"COMPLETION"
"KB_RETRIEVAL"
"KB_INPUT"
"RERANKING"
"EXTERNAL_ENDPOINT"
"PROMPT_ENGINEERING"
"DOCUMENT_INPUT"
"MAP_REDUCE"
"DOCUMENT_SEARCH"
"DOCUMENT_PROMPT"
"CUSTOM"
"CODE_EXECUTION"
"DATA_MANIPULATION"
"EVALUATION"
"FILE_RETRIEVAL"
"KB_ADD_CHUNK"
"KB_MANAGEMENT"
"GUARDRAIL"
"OUTPUT_GUARDRAIL"
"TRACER"
"AGENT_TRACER"
"AGENT_WORKFLOW"
"STANDALONE"
SpanCreate { name, start_timestamp, trace_id, 14 more }
name: string
start_timestamp: string

When the span started. With trace_id and id it forms the span’s storage identity, so a span re-sent with a start_timestamp on another UTC day is stored as a second row that the store never collapses. Get span and trace detail return the newest version. Search returns the newest version whose start_timestamp falls in the queried window. Export, metrics and facets count both rows until the trace is deleted and re-sent.

formatdate-time
trace_id: string

id for grouping traces together, uuid is recommended

maxLength256
id?: string

The id of the span, at most 256 bytes. A value longer than 256 characters is refused here with a 422 before it is forwarded; a value within that count whose UTF-8 form exceeds 256 bytes is refused with a 400 naming the field once the tracing service is the account’s primary store, and accepted for accounts still written primarily to the legacy trace store.

maxLength256
application_interaction_id?: string

The optional application interaction ID this span belongs to

application_variant_id?: string

The optional application variant ID this span belongs to

end_timestamp?: string
formatdate-time
expected?: Record<string, unknown>
group_id?: string

Reference to a group_id, at most 256 bytes. A value longer than 256 characters is refused here with a 422 before it is forwarded; a value within that count whose UTF-8 form exceeds 256 bytes is refused with a 400 naming the field once the tracing service is the account’s primary store, and accepted for accounts still written primarily to the legacy trace store.

maxLength256
input?: Record<string, unknown>
metadata?: Record<string, unknown>
obs_span_id?: string

W3C span id (16 lowercase hex chars) of the observability span this span executed in. Requires obs_trace_id.

obs_trace_id?: string

W3C trace id (32 lowercase hex chars) of the observability trace this span executed in, for correlating a business span with the infrastructure work it caused. Stored only by the sgp-traces service, so accounts still served by the legacy store accept the field and read it back as null.

output?: Record<string, unknown>
parent_id?: string

Reference to a parent span_id

status?: SpanStatus
One of the following:
"SUCCESS"
"ERROR"
"CANCELED"
type?: SpanType
One of the following:
"TEXT_INPUT"
"TEXT_OUTPUT"
"COMPLETION_INPUT"
"COMPLETION"
"KB_RETRIEVAL"
"KB_INPUT"
"RERANKING"
"EXTERNAL_ENDPOINT"
"PROMPT_ENGINEERING"
"DOCUMENT_INPUT"
"MAP_REDUCE"
"DOCUMENT_SEARCH"
"DOCUMENT_PROMPT"
"CUSTOM"
"CODE_EXECUTION"
"DATA_MANIPULATION"
"EVALUATION"
"FILE_RETRIEVAL"
"KB_ADD_CHUNK"
"KB_MANAGEMENT"
"GUARDRAIL"
"OUTPUT_GUARDRAIL"
"TRACER"
"AGENT_TRACER"
"AGENT_WORKFLOW"
"STANDALONE"
SpanStatus = "SUCCESS" | "ERROR" | "CANCELED"
One of the following:
"SUCCESS"
"ERROR"
"CANCELED"
SpanType = "TEXT_INPUT" | "TEXT_OUTPUT" | "COMPLETION_INPUT" | 23 more
One of the following:
"TEXT_INPUT"
"TEXT_OUTPUT"
"COMPLETION_INPUT"
"COMPLETION"
"KB_RETRIEVAL"
"KB_INPUT"
"RERANKING"
"EXTERNAL_ENDPOINT"
"PROMPT_ENGINEERING"
"DOCUMENT_INPUT"
"MAP_REDUCE"
"DOCUMENT_SEARCH"
"DOCUMENT_PROMPT"
"CUSTOM"
"CODE_EXECUTION"
"DATA_MANIPULATION"
"EVALUATION"
"FILE_RETRIEVAL"
"KB_ADD_CHUNK"
"KB_MANAGEMENT"
"GUARDRAIL"
"OUTPUT_GUARDRAIL"
"TRACER"
"AGENT_TRACER"
"AGENT_WORKFLOW"
"STANDALONE"