Skip to content

Commit 9a65ead

Browse files
authored
fix(dataset+decorator): item observer with top-level generation (#1055)
1 parent 224e023 commit 9a65ead

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

langfuse/decorators/langfuse_decorator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,9 @@ def _prepare_call(
364364
# Create wrapper trace if generation is top-level
365365
# Do not add wrapper trace to stack, as it does not have a corresponding end that will pop it off again
366366
trace = self.client_instance.trace(
367-
id=id, name=name, start_time=start_time
367+
id=_root_trace_id_context.get() or id,
368+
name=name,
369+
start_time=start_time,
368370
)
369371
self._set_root_trace_id(trace.id)
370372

tests/test_singleton.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import pytest
21
import threading
32
from unittest.mock import patch
3+
4+
import pytest
5+
46
from langfuse.utils.langfuse_singleton import LangfuseSingleton
57

68

@@ -64,4 +66,4 @@ def test_reset_functionality(mock_langfuse):
6466

6567
assert instance._langfuse is None
6668

67-
mock_langfuse.return_value.flush.assert_called_once()
69+
mock_langfuse.return_value.shutdown.assert_called_once()

0 commit comments

Comments
 (0)