Skip to content

bombardier: add counts for each status code received#125

Open
eusebiu-boghici wants to merge 1 commit intocodesenberg:masterfrom
eusebiu-boghici:master
Open

bombardier: add counts for each status code received#125
eusebiu-boghici wants to merge 1 commit intocodesenberg:masterfrom
eusebiu-boghici:master

Conversation

@eusebiu-boghici
Copy link

Thank you for this project!

This PR adds a new --detailed flag to bombardier. When enabled, the output (both plain-text and JSON) will include a breakdown of every unique HTTP status code received during the test. (related to #93 (comment))

Motivation and Context

Currently, bombardier aggregates status codes into 1xx, 2xx, 3xx, 4xx, and 5xx buckets. This aggregation hides important details, such as distinguishing between 400 Bad Request and 429 Too Many Requests. This feature allows users to see the exact count for each status code, providing better visibility into server behavior, especially during load testing.

Changes

1. New Flag: --detailed

  • Added the --detailed boolean flag to the command-line arguments.

2. Detailed Status Collection

  • Replaced the individual reqNxx counters in the bombardier struct with a map[int]uint64 named statusCodes, protected by a sync.Mutex.
  • The req1xx, req2xx, etc., aggregated fields are now computed dynamically from the statusCodes map during the reporting phase (gatherInfo). This ensures consistency between the detailed breakdown and the aggregate summaries.

3. Output Updates

  • Plain Text: Checks for the --detailed flag. If present, it prints a new "Detailed status codes" section, listing each code and its count in ascending order.
  • JSON: Checks for the --detailed flag. If present, it adds a statusCodes object to the result section, mapping each status code to its count.

Verification

Manual Testing

I verified the changes by running bombardier against https://www.google.com with and without the --detailed flag.

Command:

./bombardier -c 1 -n 1 --detailed https://www.google.com

Output:

Statistics        Avg      Stdev        Max
  Reqs/sec         1.25       9.25      69.86
  Latency         1.12s     0.00us      1.12s
  HTTP codes:
    1xx - 0, 2xx - 1, 3xx - 0, 4xx - 0, 5xx - 0
    others - 0
    Detailed status codes:
      200 - 1
  Throughput:    21.26KB/s

JSON Output:

{
  "spec": { ... },
  "result": {
    ...
    "req1xx": 0,
    "req2xx": 1,
    ...
    "statusCodes": {
      "200": 1
    },
    ...
  }
}

Automated Tests

I updated bombardier_test.go to reflect the internal refactoring (use of gatherInfo instead of direct field access) and confirmed that all tests pass.

ok      github.com/codesenberg/bombardier       23.929s

Display number of requests for each status code received.
Instead of having just 4xx, now you can see how many 404 and 429 were
received.
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