Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 5736afa

Browse files
committed
Merge remote-tracking branch 'master' into optimize_sample_function
2 parents 9fc3666 + cac0b30 commit 5736afa

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

.travis.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
language: go
22

33
go:
4-
- 1.3
5-
- 1.4
6-
- 1.5
7-
- 1.6
8-
- 1.7
9-
- 1.8
10-
- 1.9
4+
- "1.3"
5+
- "1.4"
6+
- "1.5"
7+
- "1.6"
8+
- "1.7"
9+
- "1.8"
10+
- "1.9"
11+
- "1.10"
12+
- "1.11"
13+
- "1.12"
1114

1215
script:
1316
- ./validate.sh

registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ type metricKV struct {
219219
}
220220

221221
func (r *StandardRegistry) registered() []metricKV {
222-
metrics := make([]metricKV, 0, len(r.metrics))
223222
r.mutex.RLock()
224223
defer r.mutex.RUnlock()
224+
metrics := make([]metricKV, 0, len(r.metrics))
225225
for name, i := range r.metrics {
226226
metrics = append(metrics, metricKV{
227227
name: name,

registry_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,17 @@ func TestConcurrentRegistryAccess(t *testing.T) {
377377
t.Fatal(i)
378378
}
379379
}
380+
381+
// exercise race detector
382+
func TestRegisterAndRegisteredConcurrency(t *testing.T) {
383+
r := NewRegistry()
384+
wg := &sync.WaitGroup{}
385+
wg.Add(1)
386+
go func(r Registry, wg *sync.WaitGroup) {
387+
defer wg.Done()
388+
r.Each(func(name string, iface interface{}) {
389+
})
390+
}(r, wg)
391+
r.Register("foo", NewCounter())
392+
wg.Wait()
393+
}

0 commit comments

Comments
 (0)