internal/telemetry/metrics: document concurrently using (#891)

Document that metricRegistry is not safe for concurrently use. While at
it, remove t.Parallel() in tests which use metricRegistry, which causes
data race, caught by:

	go test -race ./internal/telemetry/metrics
This commit is contained in:
Cuong Manh Le 2020-06-15 23:08:03 +07:00 committed by GitHub
parent e0bdd906f9
commit 34d06e521d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 6 deletions

View file

@ -11,8 +11,6 @@ import (
) )
func Test_AddGroupCacheMetrics(t *testing.T) { func Test_AddGroupCacheMetrics(t *testing.T) {
t.Parallel()
gc := &groupcache.Group{} gc := &groupcache.Group{}
AddGroupCacheMetrics(gc) AddGroupCacheMetrics(gc)
@ -40,8 +38,6 @@ func Test_AddGroupCacheMetrics(t *testing.T) {
} }
func Test_AddBoltDBMetrics(t *testing.T) { func Test_AddBoltDBMetrics(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
name string name string
stat bbolt.Stats stat bbolt.Stats
@ -68,8 +64,6 @@ func Test_AddBoltDBMetrics(t *testing.T) {
} }
func Test_AddRedisMetrics(t *testing.T) { func Test_AddRedisMetrics(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
name string name string
stat *redis.PoolStats stat *redis.PoolStats

View file

@ -18,6 +18,8 @@ var (
// metricRegistry holds the non-view metrics and handles safe // metricRegistry holds the non-view metrics and handles safe
// initialization and updates. Behavior without using newMetricRegistry() // initialization and updates. Behavior without using newMetricRegistry()
// is undefined. // is undefined.
//
// It is not safe to use metricRegistry concurrently.
type metricRegistry struct { type metricRegistry struct {
registry *metric.Registry registry *metric.Registry
buildInfo *metric.Int64Gauge buildInfo *metric.Int64Gauge