Prerequisites
Before you begin, ensure you have the following:- A LangSmith account (free to sign up)
Enable tracing
To enable tracing for your application, set the following environment variables: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’stracing_context context manager:
Log to a project
Statically
Statically
You can set a custom project name for your entire application by setting the
LANGSMITH_PROJECT environment variable:Dynamically
Dynamically
You can set the project name programmatically for specific operations:
Add metadata to traces
You can annotate your traces with custom metadata and tags:tracing_context also accepts tags and metadata for fine-grained control:
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.Python
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.