Skip to main content
LangSmith supports sending arbitrary metadata and tags along with traces. Tags are strings that can be used to categorize or label a trace. Metadata is a dictionary of key-value pairs that can be used to store additional information about a trace. Both are useful for associating additional information with a trace, such as the environment in which it was executed, the user who initiated it, or an internal correlation ID. For more information on tags and metadata, see the Concepts page. For information on how to query traces and runs by metadata and tags, see the Filter traces page.
LangSmith Deployments: To add metadata dynamically per invocation in Agent Server deployments, we recommend using tracing_context in a factory function. See Customize tracing in deployed agents for examples.

Record the code version on traces

The LangSmith SDKs can record the commit that produced a trace as a revision_id key in the metadata of every run. The SDK reads revision_id from the LANGSMITH_REVISION_ID environment variable. When that is unset, it reads LANGCHAIN_REVISION_ID, the legacy name. A revision_id set explicitly in run metadata takes precedence over both. Set the environment variable when you build or deploy your application. For example, in a Dockerfile:
Then pass the commit when building the image:
To find the traces from a given commit, filter on the revision_id metadata key. See Filter traces.