Skip to content

Commit

Permalink
Count success based on error and status code
Browse files Browse the repository at this point in the history
  • Loading branch information
parkerholladay committed Sep 1, 2023
1 parent 3b557d6 commit 4a5cee2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (m *Metrics) Add(r *Result) {
m.End = end
}

if r.Code >= 200 && r.Code < 400 {
if r.Code >= 200 && r.Code < 400 && (r.Error == "") {
m.success++
}

Expand Down
4 changes: 2 additions & 2 deletions lib/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func TestMetrics_Add(t *testing.T) {
Wait: duration("10ms"),
Requests: 10000,
Rate: 1.000100010001,
Throughput: 0.6667660098349737,
Success: 0.6667,
Throughput: 0.3333329999669967,
Success: 0.3333,
StatusCodes: map[string]int{"500": 3333, "200": 3334, "302": 3333},
Errors: []string{"Internal server error"},

Expand Down

0 comments on commit 4a5cee2

Please sign in to comment.