Skip to content

Commit

Permalink
perf(decorator): remove get_caller_module (#1074)
Browse files Browse the repository at this point in the history
  • Loading branch information
hassiebp authored Jan 14, 2025
1 parent 7497b3e commit b4d3ab9
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions langfuse/decorators/langfuse_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b4d3ab9

Please sign in to comment.