Skip to content

Commit

Permalink
Merge pull request #115 from fedorlitau/fix-racecondition-map
Browse files Browse the repository at this point in the history
Fix race contition in drawer.redrawMetrics()
  • Loading branch information
nakabonne committed Sep 14, 2021
2 parents 997f655 + c31e169 commit 7aa0ece
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion attacker/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ type ByteMetrics struct {
}

func newMetrics(m *vegeta.Metrics) *Metrics {
statusCodes := make(map[string]int, len(m.StatusCodes))
for k, v := range m.StatusCodes {
statusCodes[k] = v
}

return &Metrics{
Latencies: LatencyMetrics{
Total: m.Latencies.Total,
Expand Down Expand Up @@ -98,7 +103,7 @@ func newMetrics(m *vegeta.Metrics) *Metrics {
Rate: m.Rate,
Throughput: m.Throughput,
Success: m.Success,
StatusCodes: m.StatusCodes,
StatusCodes: statusCodes,
Errors: m.Errors,
}
}

0 comments on commit 7aa0ece

Please sign in to comment.