- Set the project and Log stream for all logs
- Get the current logger
- Flush traces
- Set the project and Log stream for a particular scope
- Manage sessions
- Get the current span and trace
galileo_context
object, in TypeScript this is available as a set of distinct top-level functions.
Set the project and Log stream
By default, Galileo uses theGALILEO_PROJECT
and GALILEO_LOG_STREAM
environment variables to determine which project and Log stream to log to. You can override this by initializing the Galileo context with a project and Log stream name.
Set the project and Log stream for a single scope in Python
You can set the project and Log stream for a scope using the Pythongalileo_context
, object in a with statement. Every log inside this block, including nested calls, will use the specified project and Log stream.
@log
decorator.
Nesting scopes
You can nestgalileo_context
calls to temporarily override the project or Log stream:
Get the current logger
The Galileo context management keeps track of loggers. You can get the current logger, which will create a new one if there isn’t an existing logger.@log
decorator, wrapped in the TypeScript log
wrapper, or created automatically by an experiment, then this will return that logger instance so you can manually add additional spans.
Flush logs
To keep your app performant, logs are not continually flushed. In some cases, you may want to flush traces explicitly:When using a Python Notebook (such as Jupyter, Google Colab, etc.), you should use the
galileo_context
and make sure to call galileo_context.flush()
at the end of your notebook.Manage sessions in Python
With the Python SDK, you can manage sessions from the context level in addition to the logger level. All the session management functions are applied to the current logger if called from the context. If you want to apply these to a specific logger instance, call the same methods directly on that logger instance. In the TypeScript SDK, these functions are only available on a GalileoLogger instance.Create a new session
To create a new session, use thestart_session
function.
Continue an existing session
If you want to add a trace to an existing session, you can use theset_session
function, passing the session ID. This is useful if you want to persist a session, for example saving a chatbot conversation with a user mid-conversation, then resuming the next time a user connects.
start_session
function.
End a session
To stop logging to a session, you can clear the current session.Next steps
Basic logging components
Galileo logger
Log with full control over sessions, traces, and spans using the Galileo logger.
Log decorator
Quickly add logging to your code with the log decorator and wrapper.
Integrations with third-party SDKs
OpenAI wrapper
Automatically log calls to the OpenAI SDK with a wrapper.
OpenAI Agents trace processor
Automatically log all the steps in your OpenAI Agent SDK apps using the Galileo trace processor.
LangChain callback
Automatically log all the steps in your LangChain or LangGraph application with the Galileo callback.