rcrowley/go-metrics — pull request #95 by rzab (2014-11-18 16:57:57+00:00)
Title: Data race between StandardRegistry.{Register,Each}

[registry.go:139](https://github.com/rcrowley/go-metrics/blob/master/registry.go#L139) does `len(r.metrics)` before the mutex lock.

The data race observed:
```
==================
WARNING: DATA RACE
Read by goroutine 19:
github.com/rcrowley/go-metrics.(*StandardRegistry).registered()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/rcrowley/go-metrics/registry.go:141 +0x63
github.com/rcrowley/go-metrics.(*StandardRegistry).Each()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/rcrowley/go-metrics/registry.go:65 +0x42
github.com/rcrowley/go-metrics/influxdb.send()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/rcrowley/go-metrics/influxdb/influxdb.go:105 +0x13a
github.com/rcrowley/go-metrics/influxdb.Influxdb()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/rcrowley/go-metrics/influxdb/influxdb.go:31 +0x334

Previous write by goroutine 32:
runtime.mapassign1()
/private/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/makerelease910109054/go/src/pkg/runtime/hashmap.goc:925 +0x0
github.com/rcrowley/go-metrics.(*StandardRegistry).register()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/rcrowley/go-metrics/registry.go:135 +0x222
github.com/rcrowley/go-metrics.(*StandardRegistry).Register()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/rcrowley/go-metrics/registry.go:99 +0xc1
github.com/rcrowley/go-metrics.NewRegisteredGauge()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/rcrowley/go-metrics/gauge.go:35 +0x176
github.com/ostrost/ostent/types.NewGaugeDiff()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/ostrost/ostent/types/types.go:442 +0x7d
github.com/ostrost/ostent.(*IndexRegistry).GetOrRegisterPrivateInterface()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/ostrost/ostent/index.go:338 +0x5b6
github.com/ostrost/ostent.(*IndexRegistry).UpdateIFdata()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/ostrost/ostent/index.go:640 +0x97
github.com/ostrost/ostent.getInterfaces()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/ostrost/ostent/interfaces.go:59 +0x296

Goroutine 19 (running) created at:
github.com/ostrost/ostent/commands.func·007()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/ostrost/ostent/commands/influxdb.go:43 +0x22b

Goroutine 32 (finished) created at:
github.com/ostrost/ostent.(*last).collect()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/ostrost/ostent/index.go:209 +0x285
github.com/ostrost/ostent.func·018()
/Users/rz/.gvm/pkgsets/go1.3.3/ostent/src/github.com/ostrost/ostent/ws.go:53 +0x156
==================
```