Skip to main content

Class: GalileoLogger

Defined in: src/utils/galileo-logger.ts:67

Constructors

Constructor

new GalileoLogger(config: GalileoLoggerConfig): GalileoLogger;
Defined in: src/utils/galileo-logger.ts:77

Parameters

config
GalileoLoggerConfig = {}

Returns

GalileoLogger

Properties

traces

traces: Trace[] = [];
Defined in: src/utils/galileo-logger.ts:74

Methods

addAgentSpan()

addAgentSpan(options: object): AgentSpan;
Defined in: src/utils/galileo-logger.ts:733 Add an agent span to the current parent. Agent spans can contain child spans (like workflow spans).

Parameters

options
Configuration for the agent span. Only input 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.
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.

addChildSpanToParent()

addChildSpanToParent(span: Span): void;
Defined in: src/utils/galileo-logger.ts:212 Add a child span to the current parent (trace or workflow/agent span). This method automatically propagates dataset information from the parent to the child span.

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.

addLlmSpan()

addLlmSpan(options: object): LlmSpan;
Defined in: src/utils/galileo-logger.ts:471 Add a new LLM span to the current parent.

Parameters

options
Configuration for the LLM span. All parameters are optional except input 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.
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.
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. 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?
any[] (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.

addRetrieverSpan()

addRetrieverSpan(options: object): RetrieverSpan;
Defined in: src/utils/galileo-logger.ts:553 Add a new retriever span to the current parent.

Parameters

options
Configuration for the retriever span. All parameters are optional except input 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.

addSingleLlmSpanTrace()

addSingleLlmSpanTrace(options: object): Trace;
Defined in: src/utils/galileo-logger.ts:340 Create a new trace with a single LLM span. This is a convenience method that combines trace creation and LLM span creation in one call. The trace is automatically concluded, so no need to call conclude().

Parameters

options
Configuration for the single LLM span trace. All parameters are optional except input 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
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?
any[] (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.

addToolSpan()

addToolSpan(options: object): ToolSpan;
Defined in: src/utils/galileo-logger.ts:613 Add a new tool span to the current parent.

Parameters

options
Configuration for the tool span. Only input 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.

addWorkflowSpan()

addWorkflowSpan(options: object): WorkflowSpan;
Defined in: src/utils/galileo-logger.ts:676 Add a workflow span to the current parent. This is useful when you want to create a nested workflow span within the trace or current workflow span. The next span you add will be a child of the current parent. To move out of the nested workflow, use conclude().

Parameters

options
Configuration for the workflow span. Only input 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.
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.

clearSession()

clearSession(): void;
Defined in: src/utils/galileo-logger.ts:254

Returns

void

conclude()

conclude(__namedParameters: object):
  | undefined
  | StepWithChildSpans;
Defined in: src/utils/galileo-logger.ts:820

Parameters

__namedParameters
concludeAll?
boolean
durationNs?
number
output?
string
redactedOutput?
string
statusCode?
number

Returns

| undefined | StepWithChildSpans

currentParent()

currentParent():
  | undefined
  | StepWithChildSpans;
Defined in: src/utils/galileo-logger.ts:196

Returns

| undefined | StepWithChildSpans

currentSessionId()

currentSessionId(): undefined | string;
Defined in: src/utils/galileo-logger.ts:202

Returns

undefined | string

flush()

flush(): Promise<Trace[]>;
Defined in: src/utils/galileo-logger.ts:853

Returns

Promise<Trace[]>

isLoggingDisabled()

isLoggingDisabled(): boolean;
Defined in: src/utils/galileo-logger.ts:160 Check if logging is disabled

Returns

boolean

setSessionId()

setSessionId(sessionId: string): void;
Defined in: src/utils/galileo-logger.ts:249

Parameters

sessionId
string

Returns

void

startSession()

startSession(__namedParameters: object): Promise<string>;
Defined in: src/utils/galileo-logger.ts:223

Parameters

__namedParameters
externalId?
string
name?
string
previousSessionId?
string

Returns

Promise<string>

startTrace()

startTrace(__namedParameters: object): Trace;
Defined in: src/utils/galileo-logger.ts:259

Parameters

__namedParameters
createdAt?
Date
datasetInput?
string
datasetMetadata?
Record<string, string>
datasetOutput?
string
durationNs?
number
input
string
metadata?
Record<string, string>
name?
string
output?
string
redactedInput?
string
redactedOutput?
string
tags?
string[]

Returns

Trace

terminate()

terminate(): Promise<void>;
Defined in: src/utils/galileo-logger.ts:894

Returns

Promise<void>

getLastOutput()

static getLastOutput(node?: BaseSpan):
  | undefined
  | {
  output?: string;
  redactedOutput?: string;
};
Defined in: src/utils/galileo-logger.ts:164

Parameters

node?
BaseSpan

Returns

| undefined | { output?: string; redactedOutput?: string; }