Skip to content

Add stats logging interface for dashboards and LLM usage - #66

Merged
kplawver merged 6 commits into
mainfrom
kplawver-stats-logging
Aug 10, 2026
Merged

Add stats logging interface for dashboards and LLM usage#66
kplawver merged 6 commits into
mainfrom
kplawver-stats-logging

Conversation

@kplawver

@kplawver kplawver commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

What does this change do?

GitHub Issue: #64

  • Adds a pluggable stats logging interface that emits machine-readable events after each review and auto-approval decision, so admins can build dashboards (Datadog, Logstash, etc.) tracking review volume, finding rates, LLM token usage/cost, and the auto-approve rate.
  • Ships JSON Lines (jsonl) and command-pipe (command) sinks behind a sink registry anyone can extend via Thingie::Stats.register_sink; events carry stable join keys (repo, PR number, commit SHA) so downstream pipelines can correlate post-merge KRI signals (revert rate, human override).
  • Enriches the review report and stats events with a real head commit SHA (was always null), and feeds accumulated LLM usage through the review + critic passes so it reaches the review.completed event.

What is risky about this change?

Low risk. Stats are off by default and require an explicit [stats] section + at least one [[stats.sinks]] entry to emit anything. All sink dispatch is fail-open (warn + skip the sink), mirroring the Approver's philosophy — a stats outage never fails a review. The commit_sha enrichment in code-review-report.json was always a schema field (round-trip safe via Report.from_hash); it's now populated instead of null. Approver#run now returns its Decision (or nil on the error path) — all existing callers ignore the return value, so no behavior change.

How to test this change?

bundle exec rake — 202 examples, 0 failures, including the yard_coverage_spec (all new classes/methods documented) and end-to-end cli_spec contexts proving reviewreview.completed JSON line on disk and github-commentapproval.decided line with block reasons. A live smoke run against a scratch repo emitted a valid review.completed event to both a stdout jsonl sink and a command sink via tee, with a real commit_sha matching the saved report.

Other Steps

None.

Emit machine-readable events after each review (review.completed) and
auto-approval decision (approval.decided) so admins can build dashboards
(Datadog, Logstash, …) tracking review volume, finding rates, token usage,
and auto-approve rate. JSON Lines and command sinks ship built-in behind a
pluggable sink registry; a real commit_sha now enriches every event and the
review report. Stats are off by default and fail-open so a stats outage
never fails a review. Issue #64.
Comment thread lib/thingie/stats/command_sink.rb
Comment thread spec/thingie/stats/command_sink_spec.rb
Comment thread lib/thingie/stats/jsonl_sink.rb
Comment thread lib/thingie/stats/events.rb
@review-thingie

review-thingie Bot commented Aug 7, 2026

Copy link
Copy Markdown
Outdated Thingie summary

✅ No issues found across 23 file(s).

pdw207
pdw207 previously approved these changes Aug 7, 2026

@pdw207 pdw207 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!!! Looks good. OK to sequence post approve revert and human override approved later. Only wish I got to this first! Not that it would be better.

Signed-off-by: Kevin Lawver <38448+kplawver@users.noreply.github.com>
@review-thingie

review-thingie Bot commented Aug 7, 2026

Copy link
Copy Markdown

✅ No issues found across 23 file(s).

@kplawver
kplawver merged commit 6af231a into main Aug 10, 2026
2 of 3 checks passed
@kplawver
kplawver deleted the kplawver-stats-logging branch August 10, 2026 12:42
@pdw207 pdw207 mentioned this pull request Aug 10, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants