Skip to main content
Defined in: src/genai/turn.ts:92

Extends

  • SpanBase

Accessors

agentName

Get Signature

get agentName(): string
Defined in: src/genai/turn.ts:103
Returns
string

model

Get Signature

get model(): string
Defined in: src/genai/turn.ts:107
Returns
string

Methods

addEvent()

Deprecated. Record this data via setAttributes instead. OpenTelemetry is phasing out the Span Event API (Span.addEvent). This method still works and existing span-event data stays valid. See https://opentelemetry.io/blog/2026/deprecating-span-events/
addEvent(name, attributes?, startTime?): this
Add a named event to the span. Useful for marking non-span moments such as context compaction, tool-loop detection, or guardrail trips. Warns and no-ops after end(). Mirrors OTel Span.addEvent. Defined in: src/genai/spanBase.ts:82

Parameters

name
string
attributes?
Attributes
startTime?
TimeInput

Returns

this

Example

Inherited from

SpanBase.addEvent

end()

end(opts?): void
Read current field values (to reflect mutations made via record() since start) and close the span. Idempotent. Pass error to mark it as failed; pass endTime to backdate the close. Defined in: src/genai/turn.ts:241

Parameters

opts?
SpanEndOptions

Returns

void

record()

record(opts): this
Bulk-set any subset of the mutable fields. Replaces (does not merge). Useful for assigning everything at once after a provider call returns. Defined in: src/genai/turn.ts:201

Parameters

opts
agentDescription?
string
agentId?
string
agentName?
string
agentVersion?
string
messages?
Message[]
model?
string
systemInstructions?
string[]

Returns

this

setAttribute()

Deprecated. Use setAttributes instead, which mirrors the Python SDK’s set_attributes and OTel’s Span.setAttributes. Retained as a thin alias so existing single-attribute callers keep working. Only Turn carries this — the other emitters never shipped a singular form.
setAttribute(key, value): this
Defined in: src/genai/turn.ts:193

Parameters

key
string
value
AttributeValue

Returns

this

setAttributes()

setAttributes(attributes): this
Set multiple attributes on the span at once. Warns and no-ops after end(). Mirrors OTel Span.setAttributes (and the Python SDK’s set_attributes). Defined in: src/genai/spanBase.ts:63

Parameters

attributes
Attributes

Returns

this

Example

Inherited from

SpanBase.setAttributes

startLLM()

startLLM(opts): LLM
Start a child LLM span under this Turn. Defined in: src/genai/turn.ts:161

Parameters

opts
LLMInit

Returns

LLM

startSubagent()

startSubagent(opts): SubAgent
Start a child SubAgent span under this Turn. Defined in: src/genai/turn.ts:179

Parameters

opts
SubAgentInit

Returns

SubAgent

startTool()

startTool(opts): Tool
Start a child Tool span under this Turn. Defined in: src/genai/turn.ts:170

Parameters

opts
ToolInit

Returns

Tool