Fix concurrent map access
parent
db9d403fd1
commit
11424a889f
|
@ -659,7 +659,9 @@ func (o *outputConfig) HTTPHandler(method string) func(r <-chan response, rt *Ti
|
|||
Precision: "ns",
|
||||
})
|
||||
for p := range r {
|
||||
o.mu.Lock()
|
||||
tags := o.tags
|
||||
o.mu.Unlock()
|
||||
tags["method"] = method
|
||||
fields := map[string]interface{}{
|
||||
"response_time": float64(p.Timer.Elapsed()),
|
||||
|
@ -668,10 +670,12 @@ func (o *outputConfig) HTTPHandler(method string) func(r <-chan response, rt *Ti
|
|||
bp.AddPoint(pt)
|
||||
if len(bp.Points())%1000 == 0 && len(bp.Points()) != 0 {
|
||||
c.Write(bp)
|
||||
o.mu.Lock()
|
||||
bp, _ = client.NewBatchPoints(client.BatchPointsConfig{
|
||||
Database: o.database,
|
||||
Precision: "ns",
|
||||
})
|
||||
o.mu.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/BurntSushi/toml"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Config is a struct for the Stress test configuration
|
||||
|
@ -102,6 +103,7 @@ type outputConfig struct {
|
|||
tags map[string]string
|
||||
addr string
|
||||
database string
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (t *outputConfig) SetParams(addr, db string) {
|
||||
|
|
Loading…
Reference in New Issue