Problem
Every AI team running production traffic in 2026 keeps an observability plane alongside the model. Cost attribution. Hallucination detection. Drift monitoring. Jailbreak signal. SLO dashboards. PII leak alerts. The open-source references — Langfuse, Phoenix, OpenLLMetry — converged on OpenTelemetry GenAI semantic conventions as the ingest schema. You can now instrument OpenAI, Anthropic, Google, LangChain, LlamaIndex, and vLLM with one SDK and ship compatible spans.
You will build a self-hosted dashboard that ingests from at least four SDK families, runs a small set of eval jobs over sampled traces, detects drift, and alerts. The measurement bar: given a deliberately injected regression (a prompt that starts producing PII), the dashboard catches it and fires an alert in under five minutes.
Concept
Ingest is OTLP HTTP. The SDK produces GenAI-semconv spans: gen_ai.system, gen_ai.request.model, gen_ai.usage.input_tokens, gen_ai.response.id, llm.prompts, llm.completions. Spans land in ClickHouse for columnar analytics; metadata (users, sessions, apps) lands in Postgres.
Evals run as batch jobs over sampled traces. DeepEval scores faithfulness, toxicity, and answer relevance. RAGAS scores retrieval metrics when the trace carries retrieval context. Custom LLM-judges run domain-specific checks (PII leak, off-policy response). Eval runs write back to the same ClickHouse as eval spans linked to the parent trace.
Drift detection watches embedding-space distributions over time (PSI or KL divergence on prompt embeddings) plus eval-score trends. Alerts feed Prometheus Alertmanager and then Slack / PagerDuty. The UI is Next.js 15 with Recharts.
Architecture
production apps:
OpenAI SDK + Anthropic SDK + Google GenAI SDK
LangChain + LlamaIndex + vLLM
|
v
OpenTelemetry SDK with GenAI semconv
|
v OTLP HTTP
collector (ingest, sample, fan-out)
|
+-------------+-----------+
v v v
ClickHouse Postgres S3 archive
(spans) (metadata) (raw events)
|
+---> eval jobs (DeepEval, RAGAS, LLM-judge)
| sampled or all-trace
| write eval spans back
|
+---> drift detector (PSI / KL on prompt embeddings)
|
+---> Prometheus metrics -> Alertmanager -> Slack / PagerDuty
|
v
Next.js 15 dashboard (Recharts)
Stack
- Ingest: OpenTelemetry SDKs + GenAI semantic conventions; OTLP HTTP transport
- Collector: OpenTelemetry Collector with tail-sampling processor (for cost control)
- Storage: ClickHouse for spans, Postgres for metadata, S3 for raw event archive
- Evals: DeepEval, RAGAS 0.2, Arize Phoenix evaluator pack, custom LLM-judge
- Drift: PSI / KL on pooled prompt embeddings (sentence-transformers) weekly
- Alerting: Prometheus Alertmanager -> Slack / PagerDuty
- UI: Next.js 15 App Router + Recharts + server actions
- SDKs supported out of the box: OpenAI, Anthropic, Google GenAI, LangChain, LlamaIndex, vLLM
Interactive figure coming later.
Build It
-
Collector config. OpenTelemetry Collector with the OTLP HTTP receiver, a tail-sampler keeping 100% of errored traces and 10% of successes, and exporters to ClickHouse and S3.
-
ClickHouse schema. Table
spanswith columns mirroring GenAI semconv:gen_ai_system,gen_ai_request_model,input_tokens,output_tokens,latency_ms,prompt_hash,trace_id,parent_span_id, plus JSON bag for long payloads. Add secondary indexes by user_id and app_id. -
SDK coverage test. Write a small client app using each SDK (OpenAI, Anthropic, Google, LangChain, LlamaIndex, vLLM) with OpenLLMetry auto-instrument. Verify each produces canonical GenAI spans that land in ClickHouse.
-
Eval jobs. A scheduled job reads last-15-min sampled traces and runs DeepEval faithfulness, toxicity, and answer relevance. Outputs are eval spans linked to the parent trace.
-
Custom LLM-judge. A PII-leak judge: given a response, call a guard LLM to score likelihood of PII leak. High-score responses land in a triage queue.
-
Drift detection. Weekly job computes PSI between this week's pooled prompt embeddings and the trailing 4-week baseline. If PSI above threshold, alert.
-
Dashboard. Next.js 15 with pages: overview (spans/sec, cost/user, p95 latency), traces (search + waterfall), evals (faithfulness trend, toxicity), drift (PSI over time), alerts.
-
Alerting chain. Prometheus exporter reads eval score aggregates and latency percentiles; Alertmanager routes to Slack for warnings and PagerDuty for critical breaches.
-
Regression probe. Inject a bug: the evaluated chatbot starts leaking fake SSNs 1% of the time. Measure MTTR: from bug deployed to Slack alert.
Use It
$ curl -X POST https://my-otel-collector/v1/traces -d @trace.json
[collector] accepted 1 trace, 3 spans
[clickhouse] inserted 3 spans (app=chat, user=u_42)
[eval] DeepEval faithfulness 0.82, toxicity 0.03
[drift] weekly PSI 0.08 (below 0.2 threshold)
[ui] live at https://obs.example.com
Ship It
outputs/skill-llm-observability.md is the deliverable. Given an LLM application, the dashboard ingests its traces, runs evals, alerts on drift, and surfaces cost/user breakdown in Next.js.
| Weight | Criterion | How it is measured |
|---|---|---|
| 25 | Trace-schema coverage | Number of SDK families producing canonical GenAI spans (target: 6+) |
| 20 | Eval correctness | DeepEval / RAGAS scores vs hand-labeled set |
| 20 | Dashboard UX | MTTR on injected regression (under 5 minutes target) |
| 20 | Cost / scale | Sustained ingest at 1k spans/sec without backlog |
| 15 | Alerting + drift detection | Prometheus/Alertmanager chain exercised end to end |
| 100 |
Exercises
-
Add custom instrumentation for the Haystack framework. Verify canonical spans land in ClickHouse with faithful
gen_ai.*attributes. -
Swap DeepEval for Phoenix evaluators on the same traces. Measure score drift between the two eval engines.
-
Sharpen the drift detector: compute PSI per app-id rather than globally. Show per-app drift trails.
-
Add a "user impact" page: cost-per-user and failure-rate-per-user with sparklines.
-
Build a tail-sampling policy that keeps 100% of traces with toxicity > 0.5 plus a 10% stratified sample of the rest. Measure sampling bias introduced.
Key Terms
| Term | What people say | What it actually means |
|---|---|---|
| GenAI semconv | "OTel LLM attributes" | 2025 OpenTelemetry spec for LLM span attributes (system, model, tokens) |
| Tail sampling | "Post-trace sample" | Collector decides to keep or drop a trace after it completes (can peek errors) |
| PSI | "Population stability index" | Drift metric comparing two distributions; > 0.2 typically signals meaningful drift |
| LLM-judge | "Eval as model" | An LLM scoring another LLM's output on a rubric (faithfulness, toxicity, PII) |
| Tail-sampling policy | "Keep-rule" | Rule that decides which traces to persist vs drop; errored + sample-rate |
| Eval span | "Linked eval trace" | Child span carrying an eval score linked to the original LLM call span |
| Cost per user | "Unit economics" | Dollar cost attributed to a user_id over a window; key product metric |
Further Reading
- Langfuse — the reference open-core observability platform
- Arize Phoenix — alternate reference with strong drift support
- OpenLLMetry (Traceloop) — auto-instrumentation SDK family
- OpenTelemetry GenAI semantic conventions — the ingest schema
- Helicone — alternate hosted observability
- Braintrust — alternate eval-first platform
- ClickHouse documentation — columnar span store
- DeepEval — evaluator library
Code
main.py
python phases/19-capstone-projects/11-llm-observability-dashboard/code/main.pyOpen on GitHub ↗ts/package.json
Open on GitHub ↗ts/README.md
Open on GitHub ↗ts/src/index.ts
npx tsx phases/19-capstone-projects/11-llm-observability-dashboard/code/ts/src/index.tsOpen on GitHub ↗ts/src/pricing.ts
npx tsx phases/19-capstone-projects/11-llm-observability-dashboard/code/ts/src/pricing.tsOpen on GitHub ↗ts/src/rollup.ts
npx tsx phases/19-capstone-projects/11-llm-observability-dashboard/code/ts/src/rollup.tsOpen on GitHub ↗ts/src/server.ts
npx tsx phases/19-capstone-projects/11-llm-observability-dashboard/code/ts/src/server.tsOpen on GitHub ↗ts/src/spans.ts
npx tsx phases/19-capstone-projects/11-llm-observability-dashboard/code/ts/src/spans.tsOpen on GitHub ↗ts/src/types.ts
npx tsx phases/19-capstone-projects/11-llm-observability-dashboard/code/ts/src/types.tsOpen on GitHub ↗ts/tests/rollup.test.ts
npx tsx phases/19-capstone-projects/11-llm-observability-dashboard/code/ts/tests/rollup.test.tsOpen on GitHub ↗ts/tests/spans.test.ts
npx tsx phases/19-capstone-projects/11-llm-observability-dashboard/code/ts/tests/spans.test.tsOpen on GitHub ↗ts/tsconfig.json
Open on GitHub ↗
Take-away files
skill-llm-observability.md
--- name: llm-observability description: Build a self-hosted LLM observability dashboard that ingests OpenTelemetry GenAI spans, runs evals, and catches injected regressions in under five minutes. version: 1.0.0 phase: 19 lesson: 11 tags: [capstone, observability, otel, langfuse, phoenix, evals, drift, clickhouse] --- Given production LLM traffic across at least six SDK families (OpenAI, Anthropic, Google GenAI, LangChain, LlamaIndex, vLLM), deploy a self-hosted observability plane that ingests OTLP GenAI-semconv spans, runs evals, detects drift, and alerts. Build plan: 1. OpenTelemetry Collector with OTLP HTTP receiver, tail-sampling processor (keep 100% errors, 10% success, 100% high-toxicity/PII), exporters to ClickHouse + S3. 2. ClickHouse span schema mirroring GenAI semconv: gen_ai.system, gen_ai.request.model, usage.input/output_tokens, latency_ms, user_id, app_id, plus JSON bag for prompts/completions. 3. Postgres metadata store for apps, users, sessions, annotation queue. 4. OpenLLMetry auto-instrumentation on a client app per SDK family; verify canonical spans land. 5. DeepEval + RAGAS + Phoenix evaluator pack scheduled over sampled traces; custom LLM-judge for PII and off-policy. 6. Weekly PSI / KL drift detector on pooled prompt embeddings; alert threshold 0.2. 7. Prometheus exporter for eval score aggregates and latency percentiles; Alertmanager to Slack (warning) + PagerDuty (critical). 8. Next.js 15 App Router dashboard: overview, trace search + waterfall, eval trends, drift chart, alerts. 9. Regression probe: inject a response pattern that leaks fake SSNs 1% of the time; measure MTTR (alert-fire time). Assessment rubric: | Weight | Criterion | Measurement | |:-:|---|---| | 25 | Trace-schema coverage | Number of SDK families producing canonical GenAI spans (target 6+) | | 20 | Eval correctness | DeepEval / RAGAS scores vs hand-labeled set | | 20 | Dashboard UX | MTTR on injected regression (target under 5 minutes) | | 20 | Cost / scale | Sustained 1k spans/sec ingest without backlog | | 15 | Alerting + drift detection | Prometheus/Alertmanager chain exercised end to end | Hard rejects: - Span schemas that invent attribute names not in the OpenTelemetry GenAI semconv. - Tail-sampling policies that drop errors (a well-known anti-pattern). - Evals that run at ingest rate without sampling (unacceptable cost). - Dashboards that show "latency" without p50/p95/p99 separation. Refusal rules: - Refuse to persist prompts or completions without a PII redaction policy. - Refuse to claim "multi-SDK support" without a per-SDK canonical-span regression test. - Refuse to ship drift detection without a baseline window; zero-shot drift is useless. Output: a repo containing the collector config, the ClickHouse schema, the Next.js 15 dashboard, the eval jobs, the drift detector, the alerting chain, the 10k-trace demo dataset with annotated regressions, and a write-up documenting MTTR for the injected PII regression plus the top three dashboard UX improvements that dropped MTTR over iteration.