Observability: Langfuse tracing + Postgres turn ledger + Grafana dashboards - #23
Merged
Merged
Conversation
…path Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…file Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Every turn dual-writes (SPEC §8): a Langfuse trace (self-hosted v3 via the compose observability profile, headless-init dev keys, trace id pinned to turn_id via an enclosing observation) and a flat Postgres row (model, tools, latency, tokens, cost, error). Feedback dual-writes by turn_id: row update + Langfuse score (flushed). Grafana provisions a 7-panel dashboard as code over the turns table, anonymous read. Replaces the JSONL feedback sink. Verified live: traced turn with exact count answer; trace/score/row all keyed to one turn_id; dashboard served without login. Closes #8 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Parent
Closes #8 — SPEC §8
What this delivers
Every turn dual-writes: a Langfuse trace (self-hosted v3 via the compose
observabilityprofile — 6 pinned services, headless-init dev keys, trace id pinned toturn_idvia an enclosing observation) and a flat Postgres row (model, tools, latency, tokens, cost, error). Feedback dual-writes by turn_id: row update + Langfuse score (flushed), replacing the JSONL sink. Grafana provisions a 7-panel dashboard as code over the turns table (volume, latency p50/p95, route split, feedback rate, cost/day, turn-error rate, tokens/day), anonymous read.Verified live: traced turn → Postgres row with real tokens/cost; trace id == turn_id (8 observations); feedback → row + score on that same trace; dashboard served without login; row lands via BackgroundTask even on client disconnect.
Review notes (two-axis /code-review; both axes converged on three hard findings — all fixed)
donehandler now stores it (one line) and the API refuses to no-op silently (logs + skips the score when the row doesn't match, preventing store divergence).${VAR:-default}isn't Grafana syntax) — plain env ref now.BackgroundTask, which Starlette runs even on disconnect; abandoned turns recorderror='client disconnected'.