Is it possible to end a trace?
So i am scraping urls of a domain and doing some analysis on top of it. For each url of that domain, I have a generation. Once all urls are done. I would want to close the trace so that the next domain gets a new trace.
1 trace for 1 domain with 5 generations (1 for each url of that domain).
I don't think it is doable since there is no trace.end() and I think I have not understood traces.
Solution:Jump to solution
I'd move the trace creation to the generateThing and create a new trace for every thing
9 Replies
How do you instrument your application? Across all our intgerations you can create a separata trace for each domain and then log the 5 llm calls as generations on this trace. The trace does not have an end as it is determined by the last observation within it
At the top of my file I have
Then these functions
Solution
I'd move the trace creation to the generateThing and create a new trace for every thing
Yes i did that, but i thought i would nest the generations under one trace.
is this standard practice?
perfect, the trace most often captures all observations within an api route, see docs for more guidance on this: https://langfuse.com/docs/tracing
LLM Application Tracing - Langfuse
Open Source LLM Observability and Tracing with Langfuse. Integrates with OpenAI, Langchain, LlamaIndex and more.
got it, i will have to create a new trace for everything or else, all generations will end up under one single trace skewing the latency, cost data
yes, I'd strongly recommend this
@Marc I moved trace creation to processDomain instead and passed that trace object to generateThing. This solved my problem of having one trace for a domain and multiple generations nested.
awesome, thanks for confirming