diff --git a/litellm/integrations/langfuse.py b/litellm/integrations/langfuse.py index c2612feb80..063b675d42 100644 --- a/litellm/integrations/langfuse.py +++ b/litellm/integrations/langfuse.py @@ -265,15 +265,17 @@ class LangFuseLogger: tags = metadata_tags trace_name = metadata.get("trace_name", None) - if trace_name is None: + trace_id = metadata.get("trace_id", None) + if trace_name is None and trace_id is None: # just log `litellm-{call_type}` as the trace name + ## DO NOT SET TRACE_NAME if trace-id set. this can lead to overwriting of past traces. trace_name = f"litellm-{kwargs.get('call_type', 'completion')}" trace_params = { "name": trace_name, "input": input, "user_id": metadata.get("trace_user_id", user_id), - "id": metadata.get("trace_id", None), + "id": trace_id, "session_id": metadata.get("session_id", None), }