Skip to content

feat(service): label review jobs with their strength - #56

Merged
TorstenDittmann merged 1 commit into
mainfrom
claude/project-thread-ccz0np
Nov 18, 2026
Merged

TorstenDittmann merged 1 commit into
mainfrom
claude/project-thread-ccz0np

Conversation

@TorstenDittmann

Copy link
Copy Markdown
Contributor

Requested by Torsten · project thread

hansi_jobs_total and hansi_job_duration_seconds now carry strength for 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

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>
@TorstenDittmann TorstenDittmann self-assigned this Nov 18, 2026
@appwrite

appwrite Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Code review

Commit Status Tier Verdict Details
cdc8268 Reviewed Reviewed 🔵 A · Mergeable after minor fixes ✅ Approved View review

The implementation appears correct, but the documented label schema is stale and the changed histogram label is not covered by a test.

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)
Finding Where
🟡 Update the documented job metric labels apps/service/src/metrics.ts:130
🟡 Assert strength on the job duration histogram too apps/service/src/metrics.test.ts:97
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)
File Change
apps/service/src/metrics.ts Adds an optional strength label to job counters and duration histograms.
apps/service/src/worker.ts Passes strength for review jobs when recording their outcome.
apps/service/src/metrics.test.ts Adds a strength label to the review job metric test fixture and counter assertion.

Reviewed cdc8268

Tip

Comment @appwrite review to re-run, or mention @appwrite with a question.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · Looks good to merge. Summary

Comment on lines +130 to +131
const labels = { type, ...(strength && { strength }) };
this.jobs.add(1, { ...labels, outcome, retry: String(retry) });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@TorstenDittmann
TorstenDittmann merged commit d976796 into main Nov 18, 2026
4 checks passed
@TorstenDittmann
TorstenDittmann deleted the claude/project-thread-ccz0np branch November 18, 2026 16:01
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