Class: Span
Defined in: src/lib/logger/components/span.ts:60 Represents a hierarchical span within a trace for grouping. Spans provide fine-grained instrumentation within traces, allowing you to organize sections of complex operations. They can contain all kinds of components within them apart from trace or session (nested spans are allowed). SpanExamples
Extends
Constructors
Constructor
new Span(Defined in: src/lib/logger/components/span.ts:72 Creates a new span log entry.config,writer):Span
Parameters
config
SpanConfig
Configuration object defining the span
writer
LogWriter
Log writer instance for persisting span data
Returns
Span
Example
Overrides
EventEmittingBaseContainer.constructor
Accessors
evaluate
Get Signature
get evaluate(): EvaluateContainer
Defined in: src/lib/logger/components/base.ts:248
Gets the evaluation methods for this container.
Example
Returns
EvaluateContainer
Evaluation methods for configuring and triggering evaluations
Inherited from
EventEmittingBaseContainer.evaluate
id
Get Signature
get id(): string
Defined in: src/lib/logger/components/base.ts:80
Gets the unique identifier for this container.
Returns
string
The container’s unique ID
Inherited from
EventEmittingBaseContainer.id
Methods
addAttachment()
addAttachment(Defined in: src/lib/logger/components/span.ts:289 Adds an attachment to this span.attachment):void
Parameters
attachment
Attachment
The attachment to add (file, data, or URL)
Returns
void
void
Example
addMetadata()
addMetadata(Defined in: src/lib/logger/components/base.ts:124 Adds metadata to this container for additional context and debugging. Any data type could be added as the value in the metadata record.metadata):void
Parameters
metadata
Record<string, unknown>
Key-value pairs of metadata
Returns
void
void
Example
Inherited from
EventEmittingBaseContainer.addMetadata
addTag()
addTag(Defined in: src/lib/logger/components/base.ts:94 Adds a tag to this container for categorization and filtering.key,value):void
Parameters
key
string
The tag key
value
string
The tag value
Returns
void
void
Example
Inherited from
EventEmittingBaseContainer.addTag
data()
data(): any
Defined in: src/lib/logger/components/base.ts:191
Returns the current data state of this container.
Returns
any
The container’s data.
Inherited from
EventEmittingBaseContainer.data
end()
end(): void
Defined in: src/lib/logger/components/base.ts:163
Marks this container as ended and records the end timestamp.
Returns
void
void
Example
Inherited from
EventEmittingBaseContainer.end
error()
error(Defined in: src/lib/logger/components/span.ts:169 Creates an error within this span.config):Error
Parameters
config
ErrorConfig
Configuration for the error
Returns
Error
A new error instance associated with this span
Example
event()
event(Defined in: src/lib/logger/components/base.ts:291 Emits a custom event within this container.id,name,tags?,metadata?):void
Parameters
id
string
Unique identifier for the event
name
string
Human-readable name for the event
tags?
Record<string, string>
Optional tags for categorizing the event
metadata?
Record<string, unknown>
Optional metadata for additional context
Returns
void
void
Example
Inherited from
EventEmittingBaseContainer.event
generation()
generation(Defined in: src/lib/logger/components/span.ts:91 Creates a new generation (LLM call) within this span.config):Generation
Parameters
config
GenerationConfig
Configuration for the generation
Returns
Generation
A new generation instance associated with this span
Example
retrieval()
retrieval(Defined in: src/lib/logger/components/span.ts:209 Creates a retrieval within this span.config):Retrieval
Parameters
config
RetrievalConfig
Configuration for the retrieval
Returns
Retrieval
A new retrieval instance associated with this span
Example
span()
span(Defined in: src/lib/logger/components/span.ts:130 Creates a nested span within this span for hierarchical organization.config):Span
Parameters
config
SpanConfig
Configuration for the nested span
Returns
Span
A new nested span instance
Example
toolCall()
toolCall(Defined in: src/lib/logger/components/span.ts:250 Creates a tool call within this span.config):ToolCall
Parameters
config
ToolCallConfig
Configuration for the tool call
Returns
ToolCall
A new tool call instance associated with this span
Example
addAttachment_()
Defined in: src/lib/logger/components/span.ts:301 Static method to add an attachment to any span by ID.staticaddAttachment_(writer,id,attachment):void
Parameters
writer
LogWriter
The log writer instance
id
string
The span ID
attachment
Attachment
The attachment to add
Returns
void
void
addMetadata_()
Defined in: src/lib/logger/components/base.ts:144 Static method to add metadata to any container by ID.staticaddMetadata_(writer,entity,id,metadata):void
Parameters
writer
LogWriter
The log writer instance
entity
Entity
The entity type
id
string
The container ID
metadata
Record<string, unknown>
The metadata to add
Returns
void
void
Inherited from
EventEmittingBaseContainer.addMetadata_
addTag_()
Defined in: src/lib/logger/components/base.ts:108 Static method to add a tag to any container by ID.staticaddTag_(writer,entity,id,key,value):void
Parameters
writer
LogWriter
The log writer instance
entity
Entity
The entity type
id
string
The container ID
key
string
The tag key
value
string
The tag value
Returns
void
void
Inherited from
EventEmittingBaseContainer.addTag_
end_()
Defined in: src/lib/logger/components/base.ts:177 Static method to end any container by ID.staticend_(writer,entity,id,data?):void
Parameters
writer
LogWriter
The log writer instance
entity
Entity
The entity type
id
string
The container ID
data?
any
Optional additional data to include with the end event
Returns
void
void
Inherited from
EventEmittingBaseContainer.end_
error_()
Defined in: src/lib/logger/components/span.ts:186 Static method to create an error associated with any span by ID.staticerror_(writer,id,config):Error
Parameters
writer
LogWriter
The log writer instance
id
string
The span ID
config
ErrorConfig
Configuration for the error
Returns
Error
A new error instance
evaluate_()
Defined in: src/lib/logger/components/base.ts:260 Static method to get evaluation methods for any evaluatable container by ID.staticevaluate_(writer,entity,id):EvaluateContainer
Parameters
writer
LogWriter
The log writer instance
entity
Entity
The entity type
id
string
The container ID
Returns
EvaluateContainer
Evaluation methods for configuring and triggering evaluations
Inherited from
EventEmittingBaseContainer.evaluate_
event_()
Defined in: src/lib/logger/components/base.ts:318 Static method to emit an event for any event-emitting container by ID.staticevent_(writer,entity,id,eventId,name,tags?,metadata?):void
Parameters
writer
LogWriter
The log writer instance
entity
Entity
The entity type
id
string
The container ID
eventId
string
Unique identifier for the event
name
string
Human-readable name for the event
tags?
Record<string, string>
Optional tags for categorizing the event
metadata?
Record<string, unknown>
Optional metadata for additional context
Returns
void
void
Inherited from
EventEmittingBaseContainer.event_
generation_()
Defined in: src/lib/logger/components/span.ts:109 Static method to create a generation associated with any span by ID.staticgeneration_(writer,id,config):Generation
Parameters
writer
LogWriter
The log writer instance
id
string
The span ID
config
GenerationConfig
Configuration for the generation
Returns
Generation
A new generation instance
retrieval_()
Defined in: src/lib/logger/components/span.ts:226 Static method to create a retrieval associated with any span by ID.staticretrieval_(writer,id,config):Retrieval
Parameters
writer
LogWriter
The log writer instance
id
string
The span ID
config
RetrievalConfig
Configuration for the retrieval
Returns
Retrieval
A new retrieval instance
span_()
Defined in: src/lib/logger/components/span.ts:147 Static method to create a nested span associated with any span by ID.staticspan_(writer,id,config):Span
Parameters
writer
LogWriter
The log writer instance
id
string
The parent span ID
config
SpanConfig
Configuration for the nested span
Returns
Span
A new nested span instance
toolCall_()
Defined in: src/lib/logger/components/span.ts:267 Static method to create a tool call associated with any span by ID.statictoolCall_(writer,id,config):ToolCall
Parameters
writer
LogWriter
The log writer instance
id
string
The span ID
config
ToolCallConfig
Configuration for the tool call
Returns
ToolCall
A new tool call instance