feat(pilot): emit per-review Langfuse traces #11

Merged
gitea_admin merged 1 commits from feat/langfuse-tracing into main 2026-08-31 13:03:15 +00:00
Owner

Ships token spend, latency and equivalent cost for every review to the self-hosted Langfuse.

langfuse_trace.py is stdlib-only and emits via the public ingestion API. Traces split into ollama and claude environments keyed off the bare model name, not the provider — both paths go through the same headroom proxy, so the provider prefix says nothing about which spend story a review belongs to. The pilot's own path bills $0, so reported cost is the equivalent price from cost_model.PRICES.

ai_review.py calls _emit_langfuse on both token-spending exit paths (normal post and salvage). Import and emission are wrapped in a blanket except: with no LANGFUSE_HOST or key pair it is a silent no-op, and telemetry failure never fails a review.

Why now: these files were previously deployed only by way of the image build's COPY . /app, so a clean checkout would have silently dropped tracing.

23 tests pass. No secrets in the diff — docs carry pk-lf-…/sk-lf-… placeholders, tests use pk-lf-test fixtures.

🤖 Generated with Claude Code

Ships token spend, latency and equivalent cost for every review to the self-hosted Langfuse. `langfuse_trace.py` is stdlib-only and emits via the public ingestion API. Traces split into `ollama` and `claude` environments keyed off the bare model name, not the provider — both paths go through the same headroom proxy, so the provider prefix says nothing about which spend story a review belongs to. The pilot's own path bills $0, so reported cost is the equivalent price from `cost_model.PRICES`. `ai_review.py` calls `_emit_langfuse` on both token-spending exit paths (normal post and salvage). Import and emission are wrapped in a blanket except: with no `LANGFUSE_HOST` or key pair it is a silent no-op, and telemetry failure never fails a review. **Why now:** these files were previously deployed only by way of the image build's `COPY . /app`, so a clean checkout would have silently dropped tracing. 23 tests pass. No secrets in the diff — docs carry `pk-lf-…`/`sk-lf-…` placeholders, tests use `pk-lf-test` fixtures. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gitea_admin added 1 commit 2026-08-31 13:03:09 +00:00
Ship token spend, latency and equivalent cost for every review to the
self-hosted Langfuse so per-model behaviour is queryable as a trend rather
than one PR comment at a time.

langfuse_trace.py is stdlib-only and emits via the public ingestion API.
Traces split into `ollama` and `claude` environments keyed off the bare model
name, not the provider: both paths go through the same headroom proxy, so the
provider prefix says nothing about which spend story a review belongs to. The
pilot's own path bills $0, so the reported cost is the equivalent price from
cost_model.PRICES.

ai_review.py calls _emit_langfuse on both token-spending exit paths (the
normal post and the salvage path). Import and emission are wrapped in a
blanket except: with no LANGFUSE_HOST or key pair the whole thing is a silent
no-op, and a telemetry failure must never fail a review.

These files were previously deployed only by way of the image build's
`COPY . /app`, so a clean checkout would have silently dropped tracing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
gitea_admin merged commit a4c35a4472 into main 2026-08-31 13:03:15 +00:00
gitea_admin deleted branch feat/langfuse-tracing 2026-08-31 13:03:15 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gitea_admin/pragent#11