Sessions
Grouping your traces into sessions
Introduction
Sessions are a way to group your traces together. They are useful when you want to group traces that are related to a single user interaction or a single request.
For example, if your application is a conversational chatbot, where at every turn in the conversation your application does several things, such as processing the user input, calling the database, and generating a response, you might want to represent each turn in the conversation as a trace, and the whole conversation as a session.
Sending sessions
Prerequisites
Make sure to install the package and get your API key from the Laminar dashboard. Read more in Installation.
Associate a trace with a session
Simply call the Laminar.set_session(session_id="session123")
within or outside any span context.
All the subsequent spans will be associated with the session.
from lmnr import Laminar as L, observe
Laminar.initialize(project_api_key=os.environ["LMNR_PROJECT_API_KEY"])
@observe()
def my_function():
L.set_session(session_id="session123")
# your code here
# optionally, at the end of the session, you can clear the session id
L.clear_session()
Viewing sessions
Go to Laminar traces page and either filter the traces by session_id or search by part of the session id in the searh bar. Because sessions are stored in span attributes, partial match search will work.