session_id / user_id per call.
LangChain/LangSmith traces can include prompts, completions, tool inputs, and tool outputs. Review Data Governance before enabling production traffic.
1. Install
Already have LangSmith and an OTLP exporter installed? Skip. No setup yet?2. Wire LangSmith OTel pointing at Agnost
The provider must be registered before importing or constructing LangChain objects. Already have an OTel TracerProvider? Append Agnost as an additional span processor:Python
langsmith/experimental/vercel is the Vercel AI SDK 7 adapter. LangChain JS/TS should use langsmith/experimental/otel/setup.
For LangChain JS/TS, keep one active OTel span around the actual invoke. The
LangSmith OTel translator attaches LangChain run data to that active span, and
the GenAI attributes below give Agnost exact Chat View input/output text.
3. Pass user_id / session_id per call
langsmith.metadata.*: Agnost reads langsmith.metadata.session_id and langsmith.metadata.user_id natively for user / session grouping.
For Chat View, keep the assistant answer in the normal LangChain output:
message content, generations, or a chain result wrapper such as answer,
output, or result. Agnost stores the raw OTel payload, then collapses those
common output shapes to readable text for the dashboard.
What appears in Agnost
- Conversations grouped by
session_id. - User-level analytics grouped by
user_id. - Raw logs for LangSmith OTel spans.
Verify
Run oneagent.invoke, then open Raw logs and confirm langsmith.metadata.session_id and langsmith.metadata.user_id exist.
Troubleshooting
- Register the
TracerProviderbefore importing LangChain. - Set
LANGSMITH_OTEL_ENABLED=trueandLANGSMITH_TRACING=true. - Set
LANGSMITH_OTEL_ONLY=trueif you do not want to also ship to LangSmith.
