loadgen: add `status` mode to the http command
Loadgen has gotten pretty complex with all the different modes and configurations. The problem is that when misconfigured, it just reports a generic failure in metrics. This makes debugging downstream harder, as consumers don't know what the error is without accessing core logs directly.
This PR adds a new status mode to the loadgen HTTP command that reports the most recent loadgen error status, if any.
Changes
LoadGenerator enhancements:
- Added
mLastErrorMessagemember to track detailed error information - Enhanced
emitFailure()to accept and store descriptive error messages - Added
getLoadGenStatus()method that returns comprehensive JSON status - Updated error paths throughout the code to provide specific error details
HTTP Command interface:
- Added "status" mode to the
generateloadHTTP command - Returns JSON response with running state, failure state, error details, and basic statistics
Testing:
- Added unit tests for the new status functionality
- Added HTTP command handler tests
Usage
Check current loadgen status:
curl 'localhost:11626/generateload?mode=status'
Example responses:
When idle:
{
"failed" : false,
"running" : false,
"total_submitted" : 0
}
When running:
{
"duration_seconds" : 15,
"failed" : false,
"running" : true,
"total_submitted" : 47
}
When failed with error details:
{
"error" : "Failed to submit transaction after 10 tries, status: 2",
"failed" : true,
"running" : false,
"total_submitted" : 23
}
This enables much easier debugging of loadgen issues without requiring direct access to stellar-core logs, making it particularly useful for monitoring systems and downstream consumers.
Fixes #4684.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.