End-to-End OpenTelemetry for a Next.js + FastAPI + Ollama App
You built an app: a Next.js frontend, a FastAPI backend, a local LLM served by Ollama, and Postgres underneath. It works. Then someone asks “why did that request take 40 seconds?” and you realize you have no idea. Was it retrieval? One of the model calls? The database? All you have is a spinner and a vibe. This post adds OpenTelemetry traces, metrics, and logs across the whole path, from a click in the browser to the token stream coming out of the model. The whole thing sits behind a single env var and is a true no-op when that var is unset, so local dev, tests, and CI never notice. Everything exports over OTLP to a Grafana LGTM stack (Loki, Grafana, Tempo, Mimir). ...