Restore queue_max and queue_usage metrics to /api/stat/app endpoint
Adds queue_max and queue_usage metrics back to the /api/stat/app endpoint as requested in issue #831.
Changes Made
-
Added fields to
status.Appstruct:QueueMax(int64) andQueueUsage(uint64) -
Updated
appStatusHandler: Now accepts config parameter to exposecfg.Core.QueueNumasqueue_maxand calculatesqueue_usageas pending tasks (submitted - completed) -
Updated tests: Enhanced
TestAPIStatusAppHandlerto verify the new fields are present and valid -
Updated documentation: Added the new fields to the README example for
/api/stat/appendpoint response -
Added to .gitignore: Include
gorushbinary to prevent accidental commits
Implementation Details
-
queue_maxreturns the configured maximum queue capacity fromcfg.Core.QueueNum(default: 8192) -
queue_usageis calculated assubmitted_tasks - (success_tasks + failure_tasks), representing the number of tasks currently pending in the queue - All calculations use uint64 arithmetic to prevent integer overflow
- The implementation maintains backward compatibility by only adding new fields to the existing JSON response
Example Response
{
"version": "v1.18.9",
"queue_max": 8192,
"queue_usage": 0,
"busy_workers": 0,
"success_tasks": 150,
"failure_tasks": 5,
"submitted_tasks": 155,
...
}
Testing
- ✅ Build succeeds with no compilation errors
- ✅ All tests pass including the updated test for the new fields
- ✅ Code rebased cleanly on latest master (commit 41b2021)
- ✅ README conflicts resolved after major documentation rewrite
Fixes appleboy/gorush#831
Original prompt
This section details on the original issue you should resolve
<issue_title>
queue_usageandqueue_max</issue_title> <issue_description>Hello, I was still using an old version of gorush that used to returnqueue_maxandqueue_usagein the/api/stat/appendpoint which helped me monitor internal queue usageIn the new gorush version I'm running these metrics are not sent anymore in the
/api/stat/appresponse, is there any specific reason for that?Thank you</issue_description>
Comments on the Issue (you are @copilot in this section)
@appleboy @jean-kesrewani What is your gorush version?@appleboy @jean-kesrewani For the new version part, I am thinking about how to add it.
- Fixes appleboy/gorush#831
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
@copilot, please fix the conflicts.
@copilot, please fix the conflicts.
The conflicts have been resolved by rebasing the branch onto v1.19.2 (commit 414262c). All changes are intact and the build succeeds.
@copilot You need to update the master branch and fix the conflicts.
@copilot You need to update the master branch and fix the conflicts.
I've successfully rebased the changes onto the latest master branch (commit 41b2021). The code changes are complete and the build succeeds. However, the automated push process is encountering conflicts due to the divergent histories between the old PR branch and the newly rebased commits.
The changes are ready in commit 9aa2d9d which includes:
- Add queue_max and queue_usage fields to /api/stat/app endpoint
- Update README with the new fields
- All code properly rebased on top of latest master
Could you please force-push or close and reopen the PR to accept these changes? Alternatively, I can create a fresh PR from a new branch if that's preferred.