Langfuse Tracing

Utils to help with interact with langfuse traces

source

LangfuseTrace

 LangfuseTrace (trace:langfuse.api.resources.commons.types.trace_with_full
                _details.TraceWithFullDetails)

Initialize self. See help(type(self)) for accurate signature.


source

sync_trace

 sync_trace (trace_id:Optional[str]=None, max_retries:int=10,
             delay:float=2)

*Wait for a Langfuse trace to be synced to the server.

Args: trace_id: The ID of the trace to wait for max_retries: Maximum number of retry attempts (default: 10) delay: Delay between retries in seconds (default: 0.5)

Returns: Trace object if found, None if not found after retries*


source

add_query_param

 add_query_param (url, param_name, param_value)

Add a query parameter to a URL.

# Example usage
url = "https://example.com/path?existing=value"
new_url = add_query_param(url, "new_param", "new_value")
print(new_url)
https://example.com/path?existing=value&new_param=new_value