Skip to main content

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.ts

Implements

  • IGalileoLogger

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

Accessors

terminated

Get Signature

get terminated(): boolean;
Defined in: src/utils/galileo-logger.ts Whether terminate() has completed on this logger. Once true, subsequent mutating calls no-op with a warning and the logger has been deregistered from the singleton (if applicable).
Returns
boolean

Implementation of

IGalileoLogger.terminated;

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?
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

IGalileoLogger.addAgentSpan;

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.

Implementation of

IGalileoLogger.addChildSpanToParent;

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.
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

IGalileoLogger.addLlmSpan;

addProtectSpan()

addProtectSpan(options: object): ToolSpan;
Defined in: src/utils/galileo-logger.ts Add a new Protect tool span to the current parent. This is a specialized method for logging Galileo Protect tool spans.

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

IGalileoLogger.addProtectSpan;

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.

Implementation of

IGalileoLogger.addRetrieverSpan;

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.
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

IGalileoLogger.addSingleLlmSpanTrace;

addSingleRetrieverSpanTrace()

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

Parameters

options
Configuration for the single retriever 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
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

IGalileoLogger.addSingleRetrieverSpanTrace;

addSingleToolSpanTrace()

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

Parameters

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

IGalileoLogger.addSingleToolSpanTrace;

addSingleWorkflowSpanTrace()

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

Parameters

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

IGalileoLogger.addSingleWorkflowSpanTrace;

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.

Implementation of

IGalileoLogger.addToolSpan;

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.
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

IGalileoLogger.addWorkflowSpan;

clearSession()

clearSession(): void;
Defined in: src/utils/galileo-logger.ts Clears the current session ID.

Returns

void

Implementation of

IGalileoLogger.clearSession;

conclude()

conclude(options: object):
  | undefined
  | StepWithChildSpans;
Defined in: src/utils/galileo-logger.ts Concludes the current trace or span, or all active traces/spans if concludeAll is true.

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

IGalileoLogger.conclude;

continueTrace()

continueTrace(traceId: string, parentId?: string): Promise<void>;
Defined in: src/utils/galileo-logger.ts Continues an existing trace (and optionally a parent span) for distributed tracing. Fetches the trace (and span if parentId is provided) from the API and sets them as current context.

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()

currentParent():
  | undefined
  | StepWithChildSpans;
Defined in: src/utils/galileo-logger.ts Get the current parent from context or instance.

Returns

| undefined | StepWithChildSpans The current parent span or trace, or undefined if none exists.

Implementation of

IGalileoLogger.currentParent;

currentSessionId()

currentSessionId(): undefined | string;
Defined in: src/utils/galileo-logger.ts Gets the current session ID.

Returns

undefined | string The current session ID, or undefined if no session is active.

Implementation of

IGalileoLogger.currentSessionId;

flush()

flush(): Promise<Trace[]>;
Defined in: src/utils/galileo-logger.ts Flushes all traces to the server. Concludes any active traces before flushing. When an ingestionHook is configured, traces are sent to the hook instead of the API and client initialization is skipped (no API credentials required).

Returns

Promise<Trace[]> A promise that resolves to an array of flushed traces.

Implementation of

IGalileoLogger.flush;

hasActiveTrace()

hasActiveTrace(): boolean;
Defined in: src/utils/galileo-logger.ts Check if there is an active trace.

Returns

boolean True if there is a current parent (trace or span), false otherwise.

Implementation of

IGalileoLogger.hasActiveTrace;

isLoggingDisabled()

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

Returns

boolean True if logging is disabled, false otherwise.

Implementation of

IGalileoLogger.isLoggingDisabled;

previousParent()

previousParent():
  | undefined
  | StepWithChildSpans;
Defined in: src/utils/galileo-logger.ts Get the previous parent (second-to-last item in the parent stack).

Returns

| undefined | StepWithChildSpans The previous parent span or trace, or undefined if less than 2 items in the stack.

Implementation of

IGalileoLogger.previousParent;

pushParent()

pushParent(span: StepWithChildSpans): void;
Defined in: src/utils/galileo-logger.ts Push a span onto the parent stack so subsequent child spans nest under it. Used by handlers that need to make leaf spans (like tool) act as parents.

Parameters

span
StepWithChildSpans

Returns

void

Implementation of

IGalileoLogger.pushParent;

setSessionId()

setSessionId(sessionId: string): void;
Defined in: src/utils/galileo-logger.ts Sets the session ID for the logger.

Parameters

sessionId
string The session ID to set.

Returns

void

Implementation of

IGalileoLogger.setSessionId;

startSession()

startSession(options: StartSessionOptions): Promise<string>;
Defined in: src/utils/galileo-logger.ts Starts a session in the active logger instance. If an externalId is provided, searches for an existing session with that external ID and reuses it if found. Note: When an existing session is found via externalId, it is returned as-is. All other options (name, previousSessionId, metadata) are ignored - they only apply when creating a new session. To update an existing session, use an explicit update method.

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

IGalileoLogger.startSession;

startTrace()

startTrace(options: object): Trace;
Defined in: src/utils/galileo-logger.ts Starts a new trace.

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

IGalileoLogger.startTrace;

terminate()

terminate(): Promise<void>;
Defined in: src/utils/galileo-logger.ts Terminates the logger. In batch mode, flushes all traces. In streaming mode, waits for all tasks to complete. After termination, subsequent mutating calls no-op with a warning, and loggers created through the singleton are removed from the singleton’s registry. Calling terminate() again is a no-op.

Returns

Promise<void> A promise that resolves when termination is complete.

Implementation of

IGalileoLogger.terminate;

create()

static create(config: GalileoLoggerConfigExtended): Promise<GalileoLogger>;
Defined in: src/utils/galileo-logger.ts 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 fails

Deprecated

Use new GalileoLogger(config) directly. For streaming traceId/spanId initialization, call initTrace/initSpan afterward. Will be made internal in a future release.

getLastOutput()

static getLastOutput(node?: BaseSpan):
  | undefined
  | {
  output?: string;
  redactedOutput?: string;
};
Defined in: src/utils/galileo-logger.ts Gets the last output from a span or its children recursively.

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.