Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

LangSmith Tracing

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.

Prerequisites

Install dependencies:

uv sync --group langsmith-tracing

Set environment variables:

export OPENAI_API_KEY="sk-..."
export LANGSMITH_API_KEY="lsv2_..."
export LANGCHAIN_TRACING_V2=true

A local Temporal server must be running (temporal server start-dev).

Three Layers of Tracing

This sample shows three complementary ways LangSmith captures trace data:

  1. Automatic (wrap_openai) — Wrapping the OpenAI client with wrap_openai() automatically creates a child span for every LLM call, capturing model parameters, token usage, and latency. No extra code needed.

  2. Explicit (@traceable) — Decorating functions with @traceable creates named spans for your business logic. You control the name, tags, metadata, and run_type (chain, llm, tool, retriever). This is how you structure traces to tell a story about what your application is doing.

  3. Temporal (add_temporal_runs=True) — The LangSmithPlugin can optionally create LangSmith runs for each Temporal workflow execution and activity execution, giving visibility into the orchestration layer alongside your LLM calls.

add_temporal_runs

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.

Further Reading