Skip to content

Instrument cleanup worker metrics#43

Merged
haasonsaas merged 1 commit intomainfrom
jonathanhaas/cleanup-worker-metrics
Apr 14, 2026
Merged

Instrument cleanup worker metrics#43
haasonsaas merged 1 commit intomainfrom
jonathanhaas/cleanup-worker-metrics

Conversation

@haasonsaas
Copy link
Copy Markdown
Collaborator

Summary\n- add cleanup pass counters and duration histograms in the worker package\n- record cleanup stats on every successful worker pass\n- expose an optional worker endpoint via or \n\n## Testing\n- go test ./internal/worker ./cmd/asb-worker\n- go test ./internal/bootstrap ./cmd/asb-api ./internal/api/httpapi ./internal/app\n- go test ./...\n- git diff --check\n

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 14, 2026

PR Summary

Medium Risk
Adds Prometheus instrumentation and an optional HTTP listener to the cleanup worker; low business-logic risk but introduces a new network surface and metrics registration behavior that could affect deployments if misconfigured.

Overview
Adds Prometheus instrumentation to the cleanup worker: a per-item-type *_cleanup_processed_total counter and *_cleanup_pass_seconds duration histogram, recorded after each successful cleanup pass.

Updates worker.Runner to accept a Metrics handle and record pass duration/stats, and extends asb-worker with an optional /metrics HTTP server (enabled via -metrics-addr / ASB_WORKER_METRICS_ADDR) with graceful shutdown. Tests now verify metrics are emitted for a cleanup run.

Reviewed by Cursor Bugbot for commit ef4f60c. Bugbot is set up for automated code reviews on this repo. Configure here.

@haasonsaas haasonsaas merged commit 3e4a2e2 into main Apr 14, 2026
4 checks passed
@haasonsaas haasonsaas deleted the jonathanhaas/cleanup-worker-metrics branch April 14, 2026 02:37
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit ef4f60c. Configure here.

return existing, nil
}
return collector, nil
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Three helper functions fully duplicated across packages

Low Severity

metricsPrefix, registerCounterVec, and registerHistogram are verbatim copies of the identical unexported functions already in internal/app/metrics.go. Any future bug fix to one copy risks being missed in the other. These could live in a shared internal package (e.g. internal/promutil) to eliminate the duplication.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ef4f60c. Configure here.

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.

1 participant