Skip to content

Commit

Permalink
feat: integrate langfuse trace class into trace service
Browse files Browse the repository at this point in the history
  • Loading branch information
italojohnny committed Aug 23, 2024
1 parent d67cb43 commit 1285ed7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/backend/base/langflow/services/tracing/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def _get_langwatch_tracer():
return LangWatchTracer


def _get_langfuse_tracer():
from langflow.services.tracing.langfuse import LangFuseTracer

return LangFuseTracer


class TracingService(Service):
name = "tracing_service"

Expand Down Expand Up @@ -101,6 +107,7 @@ async def initialize_tracers(self):
await self.start()
self._initialize_langsmith_tracer()
self._initialize_langwatch_tracer()
self._initialize_langfuse_tracer()
except Exception as e:
logger.debug(f"Error initializing tracers: {e}")

Expand All @@ -127,6 +134,16 @@ def _initialize_langwatch_tracer(self):
trace_id=self.run_id,
)

def _initialize_langfuse_tracer(self):
self.project_name = os.getenv("LANGCHAIN_PROJECT", "Langflow")
langfuse_tracer = _get_langfuse_tracer()
self._tracers["langfuse"] = langfuse_tracer(
trace_name=self.run_name,
trace_type="chain",
project_name=self.project_name,
trace_id=self.run_id,
)

def set_run_name(self, name: str):
self.run_name = name

Expand Down

0 comments on commit 1285ed7

Please sign in to comment.