Skip to main content
Temporal is a durable execution platform that enables developers to build resilient distributed applications. This guide shows you how to trace Temporal workflows and activities in LangSmith using OpenTelemetry. LangSmith supports OpenTelemetry (OTEL) trace ingestion, which integrates seamlessly with Temporal’s native OpenTelemetry interceptors. This enables full distributed tracing across your workflow executions, activities, and any LLM calls within them.

Prerequisites

  • A LangSmith account and API key
  • Temporal server running (local or cloud)
  • OpenTelemetry SDK for your language

Environment variables

Set the following environment variables for all implementations:
For regional SaaS or self-hosted LangSmith installations, also set LANGCHAIN_BASE_URL to your LangSmith instance URL.

Set up tracing

Go uses the langsmith-go SDK with Temporal’s OpenTelemetry interceptors to automatically trace workflows and activities.
1

Install

Install the LangSmith Go SDK, Temporal SDK, and OpenTelemetry interceptor:
2

Initialize tracer

Initialize the LangSmith tracer, create Temporal’s OpenTelemetry interceptor, and register it with the Temporal client and worker:
3

Define workflow and activity

Define a workflow that executes an activity. The activity demonstrates how to add custom span attributes for LangSmith visibility:
4

Execute workflow

In a separate client application, initialize the tracer and execute the workflow:
client.go

View traces in LangSmith

Once configured, traces will appear in your LangSmith project:
  1. Navigate to your LangSmith instance.
  2. Select your project.
  3. View traces in the Tracing tab.
  4. Click on individual traces to see the full span hierarchy.

Configuration options

Set a custom service name

Set a custom service name to distinguish different Temporal workers or services:

Add custom span attributes

Add custom attributes to enrich your traces:

Configure sampling

For high-volume workflows, configure sampling to reduce trace volume:

Troubleshooting

Traces not appearing

  1. Verify API key: Ensure LANGSMITH_API_KEY is set correctly
  2. Check endpoint: Confirm you’re using https://api.smith.langchain.com/otel/v1/traces
  3. Flush on shutdown: Call provider.shutdown() to flush pending spans before the application exits
  4. Check project: Verify traces are sent to the correct project (default is "default")

Missing activity spans

Ensure the tracing interceptor is configured on both the client and worker:
  • Client: Needs interceptor for starting workflows
  • Worker: Needs interceptor for executing activities

Context propagation issues

Verify propagators are configured correctly:
  • Go: langsmith.NewTracer() automatically configures propagators
  • Python/TypeScript: Ensure OpenTelemetry SDK is properly initialized with trace propagators

Worker shutdown hangs

If traces aren’t flushing, ensure you’re calling the shutdown method with proper timeout:

Next steps

Additional resources