Skip to main content
Traces are a series of steps that your application takes to go from input to output. Each of these individual steps is represented by a run. You can use LangSmith to visualize these execution steps. To use it, enable tracing for your application. This enables you to do the following:

Prerequisites

Before you begin, ensure you have the following:

Enable tracing

To enable tracing for your application, set the following environment variables:
By default, the trace will be logged to the project with the name default. To configure a custom project name, see Log to a project. For more information, see Trace with LangGraph.

Trace selectively

You may opt to trace specific invocations or parts of your application using LangSmith’s tracing_context context manager:

Log to a project

You can set a custom project name for your entire application by setting the LANGSMITH_PROJECT environment variable:
You can set the project name programmatically for specific operations:

Add metadata to traces

You can annotate your traces with custom metadata and tags:
This custom metadata and tags will be attached to the trace in LangSmith.
To learn more about how to use traces to debug, evaluate, and monitor your agents, see the LangSmith documentation.

Use anonymizers to prevent logging of sensitive data in traces

You may want to mask sensitive data to prevent it from being logged to LangSmith. You can create anonymizers and apply them to your graph using configuration. This example will redact anything matching the Social Security Number format XXX-XX-XXXX from traces sent to LangSmith.
TypeScript