This sample demonstrates LangSmith tracing integration with Temporal workflows using the LangSmithPlugin.
Two examples are included:
- basic/ — A one-shot LLM workflow that sends a prompt to OpenAI and returns the response.
- chatbot/ — A long-running conversational workflow with tool calls (save/read notes) and update handlers.
Install dependencies:
uv sync --group langsmith-tracingSet environment variables:
export OPENAI_API_KEY="sk-..."
export LANGSMITH_API_KEY="lsv2_..."
export LANGCHAIN_TRACING_V2=trueA local Temporal server must be running (temporal server start-dev).
This sample shows three complementary ways LangSmith captures trace data:
-
Automatic (
wrap_openai) — Wrapping the OpenAI client withwrap_openai()automatically creates a child span for every LLM call, capturing model parameters, token usage, and latency. No extra code needed. -
Explicit (
@traceable) — Decorating functions with@traceablecreates named spans for your business logic. You control the name, tags, metadata, andrun_type(chain, llm, tool, retriever). This is how you structure traces to tell a story about what your application is doing. -
Temporal (
add_temporal_runs=True) — TheLangSmithPlugincan optionally create LangSmith runs for each Temporal workflow execution and activity execution, giving visibility into the orchestration layer alongside your LLM calls.
By default, LangSmithPlugin(add_temporal_runs=False) only propagates LangSmith context so that @traceable and wrap_openai calls nest correctly.
Set add_temporal_runs=True to also create LangSmith runs for Temporal operations (workflow executions, activity executions, signals, etc.), giving full visibility into the orchestration layer. Both examples support a --add-temporal-runs CLI flag to toggle this.