Documentation Index
Fetch the complete documentation index at: https://docs.galileo.ai/llms.txt
Use this file to discover all available pages before exploring further.
Class: GalileoLogger
Defined in: src/utils/galileo-logger.tsImplements
IGalileoLogger
Constructors
Constructor
Parameters
config
GalileoLoggerConfig = {}
Returns
GalileoLogger
Properties
traces
Accessors
terminated
Get Signature
Returns
boolean
Implementation of
Methods
addAgentSpan()
Parameters
options
Configuration for the agent span. Onlyinput is required. This creates a parent span that can contain child spans.
agentType?
AgentType
(Optional) The type of agent. One of: ‘default’, ‘planner’, ‘react’, ‘reflection’, ‘router’, ‘classifier’, ‘supervisor’, ‘judge’. Defaults to ‘default’.
createdAt?
Date
(Optional) The timestamp when the span was created.
durationNs?
number
(Optional) Duration of the span in nanoseconds.
input
string
The input content for the agent.
metadata?
Record<string, string>
(Optional) Additional metadata as key-value pairs.
name?
string
(Optional) Name for the span (e.g., ‘Planning Agent’, ‘Router Agent’).
output?
string
(Optional) The output result from the agent.
redactedInput?
string
(Optional) Redacted version of the input.
redactedOutput?
string
(Optional) Redacted version of the output.
statusCode?
number
stepNumber?
number
(Optional) The step number in a multi-step process.
tags?
string[]
(Optional) Array of tags to categorize the span.
Returns
AgentSpan
The created agent span.
Implementation of
addChildSpanToParent()
Parameters
span
Span
The span to add as a child to the current parent.
Returns
void
Throws
Error if no trace or parent span exists.Implementation of
addLlmSpan()
Parameters
options
Configuration for the LLM span. All parameters are optional exceptinput and output.
createdAt?
Date
(Optional) The timestamp when the span was created. Defaults to current time if not provided.
durationNs?
number
(Optional) Duration of the span in nanoseconds.
events?
Event[]
(Optional) Array of events associated with the span.
input
LlmSpanAllowedInputType
The input content for the LLM span. Accepts string, Message, or arrays of these.
metadata?
Record<string, string>
(Optional) Additional metadata as key-value pairs.
model?
string
(Optional) The name or identifier of the LLM model used (e.g., ‘gpt-4o’, ‘claude-3-sonnet’).
name?
string
(Optional) Name for the span.
numCachedInputTokens?
number
numInputTokens?
number
(Optional) Number of tokens in the input.
numOutputTokens?
number
(Optional) Number of tokens in the output.
numReasoningTokens?
number
output
LlmSpanAllowedOutputType
The output content from the LLM span. Accepts string, Message, or arrays of these.
redactedInput?
LlmSpanAllowedInputType
(Optional) Redacted version of the input content.
redactedOutput?
LlmSpanAllowedOutputType
(Optional) Redacted version of the output content.
statusCode?
number
(Optional) HTTP status code or execution status (e.g., 200 for success).
stepNumber?
number
(Optional) The step number in a multi-step process.
tags?
string[]
(Optional) Array of tags to categorize the span.
temperature?
number
(Optional) The temperature parameter used for the LLM (typically 0.0-2.0).
timeToFirstTokenNs?
number
(Optional) Time to first token in nanoseconds (for streaming responses).
tools?
JsonObject[]
(Optional) Array of tool definitions available to the LLM.
totalTokens?
number
(Optional) Total number of tokens used (input + output).
Returns
LlmSpan
The created LLM span, which is automatically added to the current parent.
Implementation of
addProtectSpan()
Parameters
options
Configuration for the Protect span.createdAt?
Date
(Optional) The timestamp when the span was created.
metadata?
Record<string, string>
(Optional) Additional metadata as key-value pairs.
payload
Payload
Input to the Protect invoke method. Payload object with input and/or output attributes.
redactedPayload?
Payload
(Optional) Redacted version of the payload.
redactedResponse?
ProtectResponse
(Optional) Redacted version of the response.
response?
ProtectResponse
(Optional) Output from the Protect invoke method. Response object with text, traceMetadata, and status.
statusCode?
number
(Optional) HTTP status code or execution status (e.g., 200 for success).
stepNumber?
number
(Optional) The step number in a multi-step process.
tags?
string[]
(Optional) Array of tags to categorize the span.
Returns
ToolSpan
The created Protect tool span.
Implementation of
addRetrieverSpan()
Parameters
options
Configuration for the retriever span. All parameters are optional exceptinput and output.
createdAt?
Date
(Optional) The timestamp when the span was created.
durationNs?
number
(Optional) Duration of the span in nanoseconds.
input
string
The input query for the retriever.
metadata?
Record<string, string>
(Optional) Additional metadata as key-value pairs.
name?
string
(Optional) Name for the span.
output
RetrieverSpanAllowedOutputType
The output documents or results. Accepts string, Record<string, string>, Document, or arrays of these. Document has properties: { content: string, metadata?: Record<string, string | number | boolean> }.
redactedInput?
string
(Optional) Redacted version of the input query.
redactedOutput?
RetrieverSpanAllowedOutputType
(Optional) Redacted version of the output.
statusCode?
number
(Optional) HTTP status code or execution status (e.g., 200 for success).
stepNumber?
number
(Optional) The step number in a multi-step process.
tags?
string[]
(Optional) Array of tags to categorize the span.
Returns
RetrieverSpan
The created retriever span.
Implementation of
addSingleLlmSpanTrace()
Parameters
options
Configuration for the single LLM span trace. All parameters are optional exceptinput and output.
createdAt?
Date
(Optional) The timestamp when the span was created.
datasetInput?
string
(Optional) Input data for dataset evaluation.
datasetMetadata?
Record<string, string>
(Optional) Metadata for dataset evaluation.
datasetOutput?
string
(Optional) Expected output for dataset evaluation.
durationNs?
number
(Optional) Duration of the span in nanoseconds.
events?
Event[]
(Optional) Array of events associated with the span.
input
LlmSpanAllowedInputType
The input content for the LLM span.
metadata?
Record<string, string>
(Optional) Additional metadata as key-value pairs.
model?
string
(Optional) The name or identifier of the LLM model used (e.g., ‘gpt-4o’, ‘claude-3-sonnet’).
name?
string
(Optional) Name for the span.
numInputTokens?
number
(Optional) Number of tokens in the input.
numOutputTokens?
number
(Optional) Number of tokens in the output.
output
LlmSpanAllowedOutputType
The output content from the LLM span.
redactedInput?
LlmSpanAllowedInputType
(Optional) Redacted version of the input content.
redactedOutput?
LlmSpanAllowedOutputType
(Optional) Redacted version of the output content.
spanStepNumber?
number
(Optional) The step number for the span in a multi-step process.
statusCode?
number
(Optional) HTTP status code or execution status (e.g., 200 for success).
tags?
string[]
(Optional) Array of tags to categorize the span.
temperature?
number
(Optional) The temperature parameter used for the LLM (typically 0.0-2.0).
timeToFirstTokenNs?
number
(Optional) Time to first token in nanoseconds (for streaming).
tools?
JsonObject[]
(Optional) Array of tool definitions. Expected format: Array<{ type: ‘function’, function: { name: string, description?: string, parameters?: object } }>.
totalTokens?
number
(Optional) Total number of tokens used (input + output).
Returns
Trace
The created trace containing the single LLM span.
Throws
Error if a trace or span is already in progress.Implementation of
addSingleRetrieverSpanTrace()
Parameters
options
Configuration for the single retriever span trace. All parameters are optional exceptinput and output.
createdAt?
Date
(Optional) The timestamp when the span was created.
datasetInput?
string
(Optional) Input data for dataset evaluation.
datasetMetadata?
Record<string, string>
(Optional) Metadata for dataset evaluation.
datasetOutput?
string
(Optional) Expected output for dataset evaluation.
durationNs?
number
(Optional) Duration of the span in nanoseconds.
input
string
The input query for the retriever span.
metadata?
Record<string, string>
(Optional) Additional metadata as key-value pairs.
name?
string
(Optional) Name for the span.
output
RetrieverSpanAllowedOutputType
The output documents or results from the retriever span.
redactedInput?
string
(Optional) Redacted version of the input query.
redactedOutput?
RetrieverSpanAllowedOutputType
(Optional) Redacted version of the output.
spanStepNumber?
number
(Optional) The step number for the span in a multi-step process.
statusCode?
number
(Optional) HTTP status code or execution status (e.g., 200 for success).
tags?
string[]
(Optional) Array of tags to categorize the span.
Returns
Trace
The created trace containing the single retriever span.
Throws
Error if a trace or span is already in progress.Implementation of
addSingleToolSpanTrace()
Parameters
options
Configuration for the single tool span trace. Onlyinput is required.
createdAt?
Date
(Optional) The timestamp when the span was created.
datasetInput?
string
(Optional) Input data for dataset evaluation.
datasetMetadata?
Record<string, string>
(Optional) Metadata for dataset evaluation.
datasetOutput?
string
(Optional) Expected output for dataset evaluation.
durationNs?
number
(Optional) Duration of the span in nanoseconds.
input
string
The input parameters for the tool span.
metadata?
Record<string, string>
(Optional) Additional metadata as key-value pairs.
name?
string
(Optional) Name for the span (e.g., the tool name or function name).
output?
string
(Optional) The output result from the tool span.
redactedInput?
string
(Optional) Redacted version of the input.
redactedOutput?
string
(Optional) Redacted version of the output.
spanStepNumber?
number
(Optional) The step number for the span in a multi-step process.
statusCode?
number
(Optional) HTTP status code or execution status (e.g., 200 for success).
tags?
string[]
(Optional) Array of tags to categorize the span.
toolCallId?
string
(Optional) Unique identifier for the tool call.
Returns
Trace
The created trace containing the single tool span.
Throws
Error if a trace or span is already in progress.Implementation of
addSingleWorkflowSpanTrace()
Parameters
options
Configuration for the single workflow span trace. Onlyinput is required.
createdAt?
Date
(Optional) The timestamp when the span was created.
datasetInput?
string
(Optional) Input data for dataset evaluation.
datasetMetadata?
Record<string, string>
(Optional) Metadata for dataset evaluation.
datasetOutput?
string
(Optional) Expected output for dataset evaluation.
durationNs?
number
(Optional) Duration of the span in nanoseconds.
input
string
The input content for the workflow span.
metadata?
Record<string, string>
(Optional) Additional metadata as key-value pairs.
name?
string
(Optional) Name for the span.
output?
string
(Optional) The output result from the workflow span.
redactedInput?
string
(Optional) Redacted version of the input.
redactedOutput?
string
(Optional) Redacted version of the output.
spanStepNumber?
number
(Optional) The step number for the span in a multi-step process.
tags?
string[]
(Optional) Array of tags to categorize the span.
Returns
Trace
The created trace containing the single workflow span.
Throws
Error if a trace or span is already in progress.Implementation of
addToolSpan()
Parameters
options
Configuration for the tool span. Onlyinput is required.
createdAt?
Date
(Optional) The timestamp when the span was created.
durationNs?
number
(Optional) Duration of the span in nanoseconds.
input
string
The input parameters for the tool.
metadata?
Record<string, string>
(Optional) Additional metadata as key-value pairs.
name?
string
(Optional) Name for the span (e.g., the tool name or function name).
output?
string
(Optional) The output result from the tool.
redactedInput?
string
(Optional) Redacted version of the input.
redactedOutput?
string
(Optional) Redacted version of the output.
statusCode?
number
(Optional) HTTP status code or execution status (e.g., 200 for success).
stepNumber?
number
(Optional) The step number in a multi-step process.
tags?
string[]
(Optional) Array of tags to categorize the span.
toolCallId?
string
(Optional) Unique identifier for the tool call, typically from LLM tool_calls (e.g., ‘call_abc123’).
Returns
ToolSpan
The created tool span.
Implementation of
addWorkflowSpan()
Parameters
options
Configuration for the workflow span. Onlyinput is required. This creates a parent span that can contain child spans.
createdAt?
Date
(Optional) The timestamp when the span was created.
durationNs?
number
(Optional) Duration of the span in nanoseconds.
input
string
The input content for the workflow.
metadata?
Record<string, string>
(Optional) Additional metadata as key-value pairs.
name?
string
(Optional) Name for the span (e.g., ‘Data Processing Workflow’).
output?
string
(Optional) The output result from the workflow.
redactedInput?
string
(Optional) Redacted version of the input.
redactedOutput?
string
(Optional) Redacted version of the output.
statusCode?
number
(Optional) HTTP status code or execution status (e.g., 200 for success, 500 for error).
stepNumber?
number
(Optional) The step number in a multi-step process.
tags?
string[]
(Optional) Array of tags to categorize the span.
Returns
WorkflowSpan
The created workflow span.
Implementation of
clearSession()
Returns
void
Implementation of
conclude()
Parameters
options
Configuration for concluding.concludeAll?
boolean
(Optional) Whether to conclude all active traces/spans. Defaults to false.
durationNs?
number
(Optional) Duration in nanoseconds.
output?
string
(Optional) The output content to set.
redactedOutput?
string
(Optional) The redacted output content to set.
statusCode?
number
(Optional) HTTP status code or execution status.
Returns
|undefined
| StepWithChildSpans
The current parent after concluding, or undefined if all traces/spans were concluded.
Throws
Error if no trace or span exists to conclude.Implementation of
continueTrace()
Parameters
traceId
string
The ID of the trace to continue.
parentId?
string
(Optional) The ID of the parent span to continue under.
Returns
Promise<void>
A promise that resolves when the trace (and optional span) context is set.
currentParent()
Returns
|undefined
| StepWithChildSpans
The current parent span or trace, or undefined if none exists.
Implementation of
currentSessionId()
Returns
undefined | string
The current session ID, or undefined if no session is active.
Implementation of
flush()
Returns
Promise<Trace[]>
A promise that resolves to an array of flushed traces.
Implementation of
hasActiveTrace()
Returns
boolean
True if there is a current parent (trace or span), false otherwise.
Implementation of
isLoggingDisabled()
Returns
boolean
True if logging is disabled, false otherwise.
Implementation of
previousParent()
Returns
|undefined
| StepWithChildSpans
The previous parent span or trace, or undefined if less than 2 items in the stack.
Implementation of
pushParent()
Parameters
span
StepWithChildSpans
Returns
void
Implementation of
setSessionId()
Parameters
sessionId
string
The session ID to set.
Returns
void
Implementation of
startSession()
Parameters
options
StartSessionOptions = {}
Configuration for the session.
Returns
Promise<string>
A promise that resolves to the ID of the session (either newly created or existing).
Implementation of
startTrace()
Parameters
options
Configuration for the trace.createdAt?
Date
(Optional) The timestamp when the trace was created.
datasetInput?
string
(Optional) Input data for dataset evaluation.
datasetMetadata?
Record<string, string>
(Optional) Metadata for dataset evaluation.
datasetOutput?
string
(Optional) Expected output for dataset evaluation.
durationNs?
number
(Optional) Duration of the trace in nanoseconds.
externalId?
string
(Optional) External identifier for the trace.
input
string
The input content for the trace.
metadata?
Record<string, string>
(Optional) Additional metadata as key-value pairs.
name?
string
(Optional) Name for the trace.
output?
string
(Optional) The output content for the trace.
redactedInput?
string
(Optional) Redacted version of the input.
redactedOutput?
string
(Optional) Redacted version of the output.
tags?
string[]
(Optional) Array of tags to categorize the trace.
Returns
Trace
The created trace.
Throws
Error if a trace is already in progress.Implementation of
terminate()
Returns
Promise<void>
A promise that resolves when termination is complete.
Implementation of
create()
Internal
Static factory method to create and initialize a logger.
Use this instead of new GalileoLogger() when traceId or spanId are provided.
Parameters
config
GalileoLoggerConfigExtended = {}
Logger configuration
Returns
Promise<GalileoLogger>
Promise that resolves to a fully initialized logger
Throws
Error if config validation fails or trace/span initialization failsDeprecated
Usenew GalileoLogger(config) directly. For streaming traceId/spanId initialization, call initTrace/initSpan afterward. Will be made internal in a future release.
getLastOutput()
Parameters
node?
BaseSpan
(Optional) The span node to get output from.
Returns
|undefined
| {
output?: string;
redactedOutput?: string;
}
The output and redacted output, or undefined if not found.