Skip to content
Merged
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
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
Loading