Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/backend/base/langflow/api/v1/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,14 @@ async def on_disconnect() -> None:
media_type="text/event-stream",
)

run_id = str(uuid4())
# Use provided run_id for trace linking, or generate new UUID
if input_request and input_request.run_id:
run_id = input_request.run_id
logger.info(f"[LANGFLOW-TRACING] Using provided run_id: {run_id}")
else:
run_id = str(uuid4())
logger.info(f"[LANGFLOW-TRACING] Generated new run_id: {run_id}")

try:
result = await simple_run_flow(
flow=flow,
Expand Down
1 change: 1 addition & 0 deletions src/backend/base/langflow/api/v1/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ class SimplifiedAPIRequest(BaseModel):
)
tweaks: Tweaks | None = Field(default=None, description="The tweaks")
session_id: str | None = Field(default=None, description="The session id")
run_id: str | None = Field(default=None, description="Trace/run ID for observability linking")


# (alias) type ReactFlowJsonObject<NodeData = any, EdgeData = any> = {
Expand Down
9 changes: 8 additions & 1 deletion src/backend/base/langflow/services/tracing/langfuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ def setup_langfuse(self, config) -> bool:
except Exception as e: # noqa: BLE001
logger.debug(f"can not connect to Langfuse: {e}")
return False

# Use hex format (no dashes) to match LangFuse's internal format
if hasattr(self.trace_id, 'hex'):
trace_id_str = self.trace_id.hex
else:
trace_id_str = str(self.trace_id).replace('-', '')

self.trace = self._client.trace(
id=str(self.trace_id),
id=trace_id_str,
name=self.flow_id,
user_id=self.user_id,
session_id=self.session_id,
Expand Down
Loading