GalileoLogger
This class can be used to upload traces to Galileo. First initialize a new GalileoLogger object with an existing project and log stream.conclude.
add_agent_span
input(str): Input to the node. Expected format: String representation of agent input. Example: “User query to be processed by agent”redacted_input(Optional[str]): Input that removes any sensitive information (redacted input to the node). Same format as input parameter.output(Optional[str]): Output of the node. This can also be set on conclude(). Expected format: String representation of agent output. Example: “Agent completed task with final answer”redacted_output(Optional[str]): Output that removes any sensitive information (redacted output of the node). This can also be set on conclude(). Same format as output parameter.name(Optional[str]): Name of the span. Example: “reasoning_agent”, “planning_agent”, “router_agent”duration_ns(Optional[int]): Duration of the node in nanoseconds.created_at(Optional[datetime]): Timestamp of the span’s creation.metadata(Optional[dict[str, str]]): Metadata associated with this span. Expected format:{"key1": "value1", "key2": "value2"}tags(Optional[list[str]]): Tags associated with this span. Expected format:["tag1", "tag2", "tag3"]agent_type(Optional[AgentType]): Agent type of the span. Expected values: AgentType.CLASSIFIER, AgentType.PLANNER, AgentType.REACT, AgentType.REFLECTION, AgentType.ROUTER, AgentType.SUPERVISOR, AgentType.JUDGE, AgentType.DEFAULTstep_number(Optional[int]): Step number of the span.
AgentSpan: The created span.
add_llm_span
-
input(LlmSpanAllowedInputType): Input to the node. Expected format: List of Message objects. Example:[Message(content="Say this is a test", role=MessageRole.user)] -
output(LlmSpanAllowedOutputType): Output of the node. Expected format: Single Message object. Example:Message(content="The response text", role=MessageRole.assistant) -
model(Optional[str]): Model used for this span. Example: “gpt-4o”, “claude-4-sonnet” -
redacted_input(Optional[LlmSpanAllowedInputType]): Input that removes any sensitive information (redacted input to the node). Same format as input parameter. -
redacted_output(Optional[LlmSpanAllowedOutputType]): Output that removes any sensitive information (redacted output of the node). Same format as output parameter. -
tools(Optional[list[dict]]): List of available tools passed to LLM on invocation. Expected format for each tool dictionary: -
name(Optional[str]): Name of the span. -
duration_ns(Optional[int]): Duration of the node in nanoseconds. -
created_at(Optional[datetime]): Timestamp of the span’s creation. -
metadata(Optional[dict[str, str]]): Metadata associated with this span. Expected format:{"key1": "value1", "key2": "value2"} -
tags(Optional[list[str]]): Tags associated with this span. Expected format:["tag1", "tag2", "tag3"] -
num_input_tokens(Optional[int]): Number of input tokens. -
num_output_tokens(Optional[int]): Number of output tokens. -
total_tokens(Optional[int]): Total number of tokens. -
temperature(Optional[float]): Temperature used for generation (0.0 to 2.0). -
status_code(Optional[int]): Status code of the node execution. Expected values: 200 (success), 400 (client error), 500 (server error) -
time_to_first_token_ns(Optional[int]): Time until the first token was returned. -
step_number(Optional[int]): Step number of the span.
LlmSpan: The created span.
add_protect_span
payload(Payload): Input to the node. This is the input to the Protectinvokemethod. Expected format: Payload object with input_ and/or output attributes. Example:Payload(input_="User input text", output="Model output text")redacted_payload(Optional[Payload]): Input that removes any sensitive information (redacted input to the node). Same format as payload parameter.response(Optional[Response]): Output of the node. This is the output from the Protectinvokemethod. Expected format: Response object with text, trace_metadata, and status. Example:Response(text="Processed text", status=ExecutionStatus.triggered)redacted_response(Optional[Response]): Output that removes any sensitive information (redacted output of the node). Same format as response parameter.created_at(Optional[datetime]): Timestamp of the span’s creation.metadata(Optional[dict[str, str]]): Metadata associated with this span. Expected format:{"key1": "value1", "key2": "value2"}tags(Optional[list[str]]): Tags associated with this span. Expected format:["tag1", "tag2", "tag3"]status_code(Optional[int]): Status code of the node execution. Expected values: 200 (success), 400 (client error), 500 (server error)step_number(Optional[int]): Step number of the span.
ToolSpan: The created Protect tool span.
add_retriever_span
input(str): Input to the node.output(Union[str, list[str], dict[str, str], list[dict[str, str]], Document, list[Document], None]): Documents retrieved from the retriever.redacted_input(Optional[str]): Input that removes any sensitive information (redacted input to the node).redacted_output(Union[str, list[str], dict[str, str], list[dict[str, str]], Document, list[Document], None]): Output that removes any sensitive information (redacted documents retrieved from the retriever).name(Optional[str]): Name of the span.duration_ns(Optional[int]): Duration of the node in nanoseconds.created_at(Optional[datetime]): Timestamp of the span’s creation.metadata(Optional[dict[str, str]]): Metadata associated with this span.status_code(Optional[int]): Status code of the node execution.step_number(Optional[int]): Step number of the span.
RetrieverSpan: The created span.
add_single_llm_span_trace
-
input(LlmSpanAllowedInputType): Input to the node. Expected format: List of Message objects. Example:[Message(content="Say this is a test", role=MessageRole.user)] -
output(LlmSpanAllowedOutputType): Output of the node. Expected format: Single Message object. Example:Message(content="The response text", role=MessageRole.assistant) -
model(Optional[str]): Model used for this span. Example: “gpt-4o”, “claude-4-sonnet” -
redacted_input(Optional[LlmSpanAllowedInputType]): Input that removes any sensitive information (redacted input to the node). Same format as input parameter. -
redacted_output(Optional[LlmSpanAllowedOutputType]): Output that removes any sensitive information (redacted output of the node). Same format as output parameter. -
tools(Optional[List[dict]]): List of available tools passed to LLM on invocation. Expected format for each tool dictionary: -
name(Optional[str]): Name of the span. -
duration_ns(Optional[int]): Duration of the node in nanoseconds. -
created_at(Optional[datetime]): Timestamp of the span’s creation. -
metadata(Optional[dict[str, str]]): Metadata associated with this span. Expected format:{"key1": "value1", "key2": "value2"} -
tags(Optional[list[str]]): Tags associated with this span. Expected format:["tag1", "tag2", "tag3"] -
num_input_tokens(Optional[int]): Number of input tokens. -
num_output_tokens(Optional[int]): Number of output tokens. -
total_tokens(Optional[int]): Total number of tokens. -
temperature(Optional[float]): Temperature used for generation (0.0 to 2.0). -
status_code(Optional[int]): Status code of the node execution. Expected values: 200 (success), 400 (client error), 500 (server error) -
time_to_first_token_ns(Optional[int]): Time until the first token was returned. -
dataset_input(Optional[str]): Input from the associated dataset. -
dataset_output(Optional[str]): Expected output from the associated dataset. -
dataset_metadata(Optional[dict[str, str]]): Metadata from the associated dataset. Expected format:{"key1": "value1", "key2": "value2"} -
span_step_number(Optional[int]): Step number of the span.
Trace: The created trace.
add_tool_span
input(str): Input to the node. Expected format: String representation of tool input/arguments. Example: “search_query: python best practices”redacted_input(Optional[str]): Input that removes any sensitive information (redacted input to the node). Same format as input parameter.output(Optional[str]): Output of the node. Expected format: String representation of tool result. Example: “Found 10 results for python best practices”redacted_output(Optional[str]): Output that removes any sensitive information (redacted output of the node). Same format as output parameter.name(Optional[str]): Name of the span. Example: “search_tool”, “calculator”, “weather_api”duration_ns(Optional[int]): Duration of the node in nanoseconds.created_at(Optional[datetime]): Timestamp of the span’s creation.metadata(Optional[dict[str, str]]): Metadata associated with this span. Expected format:{"key1": "value1", "key2": "value2"}tags(Optional[list[str]]): Tags associated with this span. Expected format:["tag1", "tag2", "tag3"]status_code(Optional[int]): Status code of the node execution. Expected values: 200 (success), 400 (client error), 500 (server error)tool_call_id(Optional[str]): Tool call ID. Expected format: Unique identifier for the tool call.step_number(Optional[int]): Step number of the span.
ToolSpan: The created span.
add_workflow_span
input(str): Input to the node. Expected format: String representation of workflow input. Example: “Start workflow with user request: analyze data”redacted_input(Optional[str]): Input that removes any sensitive information (redacted input to the node). Same format as input parameter.output(Optional[str]): Output of the node. This can also be set on conclude(). Expected format: String representation of workflow output. Example: “Workflow completed successfully with results”redacted_output(Optional[str]): Output that removes any sensitive information (redacted output of the node). This can also be set on conclude(). Same format as output parameter.name(Optional[str]): Name of the span. Example: “data_analysis_workflow”, “user_onboarding_flow”duration_ns(Optional[int]): Duration of the node in nanoseconds.created_at(Optional[datetime]): Timestamp of the span’s creation.metadata(Optional[dict[str, str]]): Metadata associated with this span. Expected format:{"key1": "value1", "key2": "value2"}tags(Optional[list[str]]): Tags associated with this span. Expected format:["tag1", "tag2", "tag3"]step_number(Optional[int]): Step number of the span.
WorkflowSpan: The created span.
async_flush
List[Trace]: The list of uploaded traces.
async_ingest_traces
ingestion_hook to ingest modified traces.
async_start_session
name(Optional[str]:): Name of the session. Only used to set name for new sessions. If not provided, a session name will be generated automatically. Example: “user_session_123”, “customer_support_chat”previous_session_id(Optional[str]): ID of the previous session. Expected format: UUID string format. Example: “12345678-1234-5678-9012-123456789012”external_id(Optional[str]): External ID of the session. If a session in the current project and log stream with this external ID is found, it will be used instead of creating a new one. Expected format: Unique identifier string. Example: “user_session_abc123”, “support_ticket_456”
str: The ID of the session (existing or newly created).
conclude
output(Optional[str]): Output of the node.redacted_output(Optional[str]): Output that removes any sensitive information (redacted output of the node).duration_ns(Optional[int]): Duration of the node in nanoseconds.status_code(Optional[int]): Status code of the node execution.conclude_all(bool): If True, all spans will be concluded, including the current span. False by default.
Optional[StepWithChildSpans]: The parent of the current workflow. None if no parent exists.
flush
List[Trace]: The list of uploaded traces.
get_tracing_headers
GalileoLoggerException: If not in distributed mode or if no trace has been started.
dict[str, str]: Dictionary with the following headers:- X-Galileo-Trace-ID: The root trace ID
- X-Galileo-Parent-ID: The ID of the current parent (trace or span) that downstream spans should attach to
ingest_traces
ingestion_hook to ingest modified traces.
set_session
session_id(str): ID of the session to set.
start_session
name(Optional[str]): Name of the session. If omitted, the server will assign a name. Example: “user_session_123”, “customer_support_chat”previous_session_id(Optional[str]): UUID string of a prior session to link to. Expected format: UUID string format. Example: “12345678-1234-5678-9012-123456789012”external_id(Optional[str]): External identifier to dedupe against existing sessions within the same project/log stream or experiment; if found, that session will be reused instead of creating a new one. Expected format: Unique identifier string. Example: “user_session_abc123”, “support_ticket_456”
str: The ID of the session (existing or newly created).
start_trace
input(StepAllowedInputType | dict): Input to the node. Expected format: String, dict (auto-converted to JSON), or sequence of Message objects. Examples -- String: “User query: What is the weather today?”
- Dict:
{"query": "hello", "context": "world"}(auto-converted to JSON string) - Messages:
[Message(content="Hello", role=MessageRole.user)]
redacted_input(Optional[StepAllowedInputType | dict]): Input that removes any sensitive information (redacted input). Same format as input parameter.name(Optional[str]): Name of the trace. Example: “weather_query_trace”, “customer_support_session”duration_ns(Optional[int]): Duration of the trace in nanoseconds.created_at(Optional[datetime]): Timestamp of the trace’s creation.metadata(Optional[dict[str, MetadataValue]]): Metadata associated with this trace. Expected format:{"key1": "value1", "enabled": True, "count": 42}Accepted value types: str, bool, int, float, None (auto-converted to strings). Note: Nested structures (dict, list) are NOT supported by the API.tags(Optional[list[str]]): Tags associated with this trace. Expected format:["tag1", "tag2", "tag3"]dataset_input(Optional[str]): Input from the associated dataset.dataset_output(Optional[str]): Expected output from the associated dataset.dataset_metadata(Optional[dict[str, MetadataValue]]): Metadata from the associated dataset. Expected format:{"key1": "value1", "enabled": True, "count": 42}Accepted value types: str, bool, int, float, None (auto-converted to strings).external_id(Optional[str]): External ID for this trace to connect to external systems. Expected format: Unique identifier string.
Trace: The created trace.