dspy icon indicating copy to clipboard operation
dspy copied to clipboard

How to get LangFuse trace_id

Open raghavbali opened this issue 5 months ago • 9 comments

Hey dspy team, I am trying to use langfuse tracer to trace my usage and most importantly capture cost. The place where I am struggling at the moment is getting hold of trace_id for each request that is generated with LLMs (eg: openai). I am able to get to the whole list of traces using TracerObject.langfuse.fetch_traces() and then using the data attribute to get to total_cost but this requires a whole lot of processing to filter the actual traces I am looking for.

Is there a cleaner way I can make use of fetch_trace_id() method without creating a custom tracer? From what I understand the default implementation is not passing any id and expecting LangFuse to generate random trace ids.

PS: Kudos on the Amazing work in getting this integration in place

raghavbali avatar Sep 25 '24 13:09 raghavbali