Skip to main content

Class: GalileoLogger

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

Constructors

Constructor

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

Parameters

config
GalileoLoggerConfig = {}

Returns

GalileoLogger

Properties

traces

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

Methods

addAgentSpan()

addAgentSpan(options: object): AgentSpan;
Defined in: src/utils/galileo-logger.ts 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?
| "default" | "planner" | "react" | "reflection" | "router" | "classifier" | "supervisor" | "judge" (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 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 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 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 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 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 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

Returns

void

conclude()

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

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

Returns

| undefined | StepWithChildSpans

currentSessionId()

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

Returns

undefined | string

flush()

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

Returns

Promise<Trace[]>

isLoggingDisabled()

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

Returns

boolean

setSessionId()

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

Parameters

sessionId
string

Returns

void

startSession()

startSession(options: object): Promise<string>;
Defined in: src/utils/galileo-logger.ts Start a session in the active logger instance. If an externalId is provided, the method will first search for an existing session with that external ID. If found, it will reuse that session instead of creating a new one. This allows you to maintain persistent sessions across multiple runs or associate sessions with external identifiers (e.g., user IDs, conversation IDs).

Parameters

options
Configuration for the session
externalId?
string An external identifier for the session. If a session with this external ID already exists, it will be reused instead of creating a new session (optional)
name?
string The name of the session (optional)
previousSessionId?
string The ID of a previous session to link to (optional)

Returns

Promise<string> The ID of the session (either newly created or existing)

startTrace()

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

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

Returns

Promise<void>

getLastOutput()

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

Parameters

node?
BaseSpan

Returns

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