Repository navigation
feat(service): label review jobs with their strength - #56
Conversation
hansi_jobs_total and hansi_job_duration_seconds now carry the strength a review ran at, as the model metrics already do, so the dashboard can divide cost by reviews done for one strength. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F3M7ttqrBNFxYGUUt1NRti Co-authored-by: Torsten Dittmann <1759475+TorstenDittmann@users.noreply.github.com>
Code review
The worker now passes review strength into the job metrics, and the metrics attach it to review job counters and durations. Chat and invalid job metrics continue to omit strength labels. Findings (2)
Fix with agent prompt### Issue 1
apps/service/src/metrics.ts:130-131
**Update the documented job metric labels**
The README metrics table at rows 202–203 still lists the old label sets, so it no longer describes the labels emitted for review jobs. Please update those rows to note that `strength` is present for reviews and absent for chat/invalid jobs.
### Issue 2
apps/service/src/metrics.test.ts:97
**Assert strength on the job duration histogram too**
This only verifies the new label on `hansi_jobs_total`; the separately recorded `hansi_job_duration_seconds` label is not asserted anywhere. A regression that drops strength from the duration histogram would leave this test passing despite that metric being part of the change.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Walkthrough (3)
Reviewed Tip Comment |
| const labels = { type, ...(strength && { strength }) }; | ||
| this.jobs.add(1, { ...labels, outcome, retry: String(retry) }); |
There was a problem hiding this comment.
Update the documented job metric labels
The README metrics table at rows 202–203 still lists the old label sets, so it no longer describes the labels emitted for review jobs. Please update those rows to note that strength is present for reviews and absent for chat/invalid jobs.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/service/src/metrics.ts
Line: 130-131
Comment:
**Update the documented job metric labels**
The README metrics table at rows 202–203 still lists the old label sets, so it no longer describes the labels emitted for review jobs. Please update those rows to note that `strength` is present for reviews and absent for chat/invalid jobs.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · documentation · Reply if this doesn't apply.
| const jobs = (await reader.points('hansi_jobs_total')).map((p) => [p.attributes, p.value]); | ||
| expect(jobs).toEqual([ | ||
| [{ type: 'review', outcome: 'done', retry: 'false' }, 1], | ||
| [{ type: 'review', strength: 'expert', outcome: 'done', retry: 'false' }, 1], |
There was a problem hiding this comment.
Assert strength on the job duration histogram too
This only verifies the new label on hansi_jobs_total; the separately recorded hansi_job_duration_seconds label is not asserted anywhere. A regression that drops strength from the duration histogram would leave this test passing despite that metric being part of the change.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/service/src/metrics.test.ts
Line: 97
Comment:
**Assert strength on the job duration histogram too**
This only verifies the new label on `hansi_jobs_total`; the separately recorded `hansi_job_duration_seconds` label is not asserted anywhere. A regression that drops strength from the duration histogram would leave this test passing despite that metric being part of the change.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · testing · Reply if this doesn't apply.

Requested by Torsten · project thread
hansi_jobs_totalandhansi_job_duration_secondsnow carrystrengthfor review jobs, as the model metrics already do. Chat and invalid jobs stay without it.This lets the Grafana dashboard divide cost by reviews done for a single strength (the strength filter in appwrite-labs/monitoring).
Tests, type check and lint pass.
Generated by Claude Code