Skip to content

Commit

Permalink
Fix race contition in drawer.redrawMetrics() (fatal error: concurrent…
Browse files Browse the repository at this point in the history
… map iteration and map write)
  • Loading branch information
fedorlitau committed Sep 14, 2021
1 parent 997f655 commit c31e169
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 c31e169

Please sign in to comment.