Module
Galileo Decorator Module. This module provides decorators for logging and tracing function calls in your application. Decorators allow you to add logging functionality to your existing code with minimal changes. How to use decorators:- 
Basic usage - decorate any function to log its execution:
- 
You can annotate your logs to help categorize and search logs later on:
In this case, we are using:- span_type - This groups the logs here into the “llm” category.
- name - This assigns a searchable name to all logs within this function.
 
- 
Using context manager for grouping related operations:
- Galileo API key must be set (via environment variable GALILEO_API_KEY or programmatically)
- Project and Log Stream names should be defined if using the logdecorator (either via environment variables GALILEO_PROJECT and GALILEO_LOG_STREAM, or viagalileo_context.init())
GalileoDecorator
Main decorator class that provides both decorator and context manager functionality for logging and tracing in Galileo. This class can be used as:- A function decorator via the logmethod
- A context manager via the __call__method
clear_session
flush
- project: The project name. Defaults to None.
- log_stream: The log stream name. Defaults to None.
flush_all
get_current_log_stream
- str | None: The current log stream context
get_current_mode
- str:
get_current_project
- str | None: The current project context
get_current_span_stack
- List[WorkflowSpan]: The current span stack
get_current_trace
- Trace | None: The current trace
get_logger_instance
- project: Optional project name to use
- log_stream: Optional log stream name to use
- GalileoLogger instance configured with the specified project and log stream:
init
- project: The project name. Defaults to None.
- log_stream: The log stream name. Defaults to None.
- experiment_id: The experiment id. Defaults to None.
- local_metrics: Local metrics configs to run on the traces/spans before submitting them for ingestion. Defaults to None.
log
- @log
- @log(name=“my_function”, span_type=“llm”)
- func: The function to decorate (when used without parentheses)
- name: Optional custom name for the span (defaults to function name)
- span_type: Optional span type (“llm”, “retriever”, “tool”, “workflow”, “agent”)
- params: Optional parameter mapping for extracting specific values
- dataset_record: Optional parameter for dataset values. This is used by the local experiment module to set the dataset fields on the trace/spans and not generally provided for logging to log streams.
- A decorated function that logs its execution:
reset
reset_trace_context
set_session
- session_id: The id of the session to set.
start_session
- name: The name of the session. If not provided, a session name will be generated automatically.
- previous_session_id: The id of the previous session. Defaults to None.
- external_id: The external id of the session. Defaults to None.
- str: The id of the newly created session.