Basic Features
Sessions
5 min
many interactions with llm applications span multiple traces sessions in abv are a way to group these traces together and see a simple session replay of the entire interaction get started by adding a sessionid when creating a trace add a sessionid when creating/updating a trace this can be any string that you use to identify the session all traces with the same sessionid will be grouped together implementation with python sdk when using the @observe() decorator from abvdev import observe, get client @observe() def process request() \# get the client abv = get client() \# add to the current trace abv update current trace(session id="your session id") \# your processing logic return result when creating spans directly from abvdev import get client abv = get client() \# you can set the session id when creating the root span with abv start as current span( name="process chat message" ) as root span \# add session id to the trace root span update trace(session id="chat session 123") \# all spans in this trace will belong to the same session with root span start as current generation( name="generate response", model="gpt 4o" ) as gen \# generate response pass you can also update the session id of the current trace without a direct reference to a span with abv start as current span(name="another operation") \# add to the current trace abv update current trace(session id="your session id") implementation with js/ts sdk when using the context manager import { startactiveobservation, startobservation, updateactivetrace, } from "@abvdev/tracing"; await startactiveobservation("context manager", async (span) => { span update({ input { query "what is the capital of france?" }, }); // set sessionid on the trace updateactivetrace({ sessionid "session 123", }); }); when using the observe wrapper import { observe, updateactivetrace } from "@abvdev/tracing"; // an existing function async function fetchdata(source string) { // set sessionid on the trace updateactivetrace({ sessionid "session 123", }); // logic to fetch data return { data `some data from ${source}` }; } // wrap the function to trace it const tracedfetchdata = observe(fetchdata, { name "observe wrapper", }); const result = await tracedfetchdata("api"); when creating spans manually import { startobservation } from "@abvdev/tracing"; const span = startobservation("manual observation", { input { query "what is the capital of france?" }, }); // set sessionid on the trace span updatetrace({ sessionid "session 123", }); span update({ output "paris" }) end(); see typescript sdk overview docid\ j4sdnlmdmnfmk99ootgn7 for more details example example session spanning multiple traces