From 275e2c304346602ddd7eb1cad7a9791a2e5df90e Mon Sep 17 00:00:00 2001 From: Hassieb Pakzad <68423100+hassiebp@users.noreply.github.com> Date: Tue, 14 Jan 2025 10:37:02 +0100 Subject: [PATCH] perf(decorator): remove get_caller_module --- langfuse/decorators/langfuse_decorator.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/langfuse/decorators/langfuse_decorator.py b/langfuse/decorators/langfuse_decorator.py index b53427f34..45ae548c6 100644 --- a/langfuse/decorators/langfuse_decorator.py +++ b/langfuse/decorators/langfuse_decorator.py @@ -676,26 +676,12 @@ def get_current_trace_id(self): return context_trace_id stack = _observation_stack_context.get() - should_log_warning = self._get_caller_module_name() != "langfuse.openai" if not stack: - if should_log_warning: - self._log.warning("No trace found in the current context") - return None return stack[0].id - def _get_caller_module_name(self): - try: - caller_module = inspect.getmodule(inspect.stack()[2][0]) - except Exception as e: - self._log.warning(f"Failed to get caller module: {e}") - - return None - - return caller_module.__name__ if caller_module else None - def get_current_trace_url(self) -> Optional[str]: """Retrieve the URL of the current trace in context. @@ -738,12 +724,8 @@ def get_current_observation_id(self): - If called at the top level of a trace, it will return the trace ID. """ stack = _observation_stack_context.get() - should_log_warning = self._get_caller_module_name() != "langfuse.openai" if not stack: - if should_log_warning: - self._log.warning("No observation found in the current context") - return None return stack[-1].id