AI / LangGraph LangChain Interview questions II
How do you monitor LangChain applications?
Monitoring LangChain applications in production means tracking latency, error rates, token usage, and response quality over time. LangSmith is the primary tool, but you can also integrate with standard observability infrastructure.
LangSmith tracing — enabled with two env vars, it captures every run automatically with full context:
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=ls__...
export LANGCHAIN_PROJECT=production-chat-v2
In LangSmith you get: latency distribution per chain step, error rate trends, token cost per request, feedback scores from users or evaluators, and the ability to filter/search runs by any metadata tag you add.
Custom metadata tagging — tag runs with user ID, feature flag, model version, etc. to enable filtering in LangSmith dashboards:
chain.invoke(
{"input": user_query},
config={
"metadata": {"user_id": user_id, "ab_group": "control"},
"tags": ["production", "rag-v2"],
}
)
Custom callbacks for metrics — implement a callback handler that pushes latency, token counts, and error flags to your existing metrics backend (Prometheus, Datadog, CloudWatch) on each LLM call end:
class MetricsCallback(BaseCallbackHandler):
def on_llm_end(self, response, **kwargs):
tokens = response.llm_output.get("token_usage", {})
prometheus_counter.inc(tokens.get("total_tokens", 0))
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
