Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw committed Dec 18, 2024
1 parent f5d7eee commit ab37410
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/core/langchain_core/callbacks/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2379,6 +2379,7 @@ def _configure(
if run_tree is not None
else tracing_context["client"]
),
tags=tracing_tags,
)
callback_manager.add_handler(handler, True)
except Exception as e:
Expand Down
19 changes: 19 additions & 0 deletions libs/core/tests/unit_tests/runnables/test_tracing_interops.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ def _get_posts(client: Client) -> list:
return posts


def test_tracing_context() -> None:
mock_session = MagicMock()
mock_client_ = Client(
session=mock_session, api_key="test", auto_batch_tracing=False
)

@RunnableLambda
def my_function(a: int) -> int:
return a + 1

name = uuid.uuid4().hex
project_name = f"Some project {name}"
with tracing_context(project_name=project_name, client=mock_client_):
assert my_function.invoke(1) == 2
posts = _get_posts(mock_client_)
assert posts
assert all(post["session_name"] == project_name for post in posts)


def test_config_traceable_handoff() -> None:
get_env_var.cache_clear()
mock_session = MagicMock()
Expand Down

0 comments on commit ab37410

Please sign in to comment.