Skip to content

Added support for LangSmith tracing across workflows and activities #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 2, 2025

Conversation

mfateev
Copy link
Member

@mfateev mfateev commented May 29, 2025

What was changed

Added an interceptor that propagates LangSmith tracing headers as well as creates corresponding spans for Temporal workflows and activities.

Why?

Enable LangSmith visibility for workflows that use LangChain.

@mfateev mfateev requested a review from a team as a code owner May 29, 2025 21:43
# with trace(...):
# return await self.next.execute_workflow(input)
with temporalio.workflow.unsafe.sandbox_unrestricted():
t = trace(name=f"execute_workflow:{name}", run_id=workflow.info().run_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any concerns with tracing during replay here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see any duplicated traces in the UI when the replay was forced.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we never really had tests for the langchain sample, so don't have to add as part of this, but we should probably make an issue to add them at some point. We've found cases where these integration-type examples become stale or stop working with new dependency versions and there are no tests to confirm that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how a local test would help, as they don't have an embeddable version of Langsmith.

Copy link
Member

@cretz cretz Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is unfortunate. Ideally we'd test the same way they encourage users to test using the in-memory representations or mocks they suggest. But we do often not test integrations in this repo.

@mfateev mfateev force-pushed the langchaintracing branch from 1850350 to a0eb654 Compare May 30, 2025 18:27
Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @dandavison - do you want to add anything?


from temporalio import workflow

with workflow.unsafe.imports_passed_through():
from dataclasses import dataclass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Standard library packages re already passed through

@mfateev mfateev merged commit 5d64065 into temporalio:main Jun 2, 2025
11 checks passed
jssmith pushed a commit that referenced this pull request Jun 18, 2025
…188)

* Added langchain tracing interceptor. Changed sample to use a child workflow and multiple activities.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants