Logging
Logging allows you to annotate a Trace
with important information for troubleshooting and debugging. Your log statements are tied to a Trace
which makes it easy to collect and analyze important information quickly and systematically. You can use logging to understand user behavior, streamline debugging, and identify areas of improvement for your RAG system.
Writing Logs
Log statements are 1:1 with a specific trace. First, you need to instantiate a LastMile Tracer.
tracer: LastMileTracer = get_lastmile_tracer(
tracer_name="my-tracer",
project_name="Quick-Start-LM"
)
To write logs in your code, use the tracer.log()
method provided by LastMile Tracing SDK.
@tracer.trace_function()
def retrieve_context(query_string: str, top_k: int = 5) -> list[str]:
# Log statement
tracer.log("Test retrieval from non-English user query")
...
return documents_parsed_as_strings
Now your log statement has been logged to your Trace!
Viewing Logs
You can view your logs in the RAG Workbench UI.
Run the following command in your terminal to launch the UI:
rag-debug launch
Navigate to the url provided by the RAG Workbench (opens up your web browser). This will look like http://localhost:8080/
- Click the Traces Tab.
- Select your Project.
- Click on a Trace within your Project.
- View the Logs for that Trace.
Example of Logs for a Trace:
More Resources
Here are other helpful guides related to logging: