telmetry: add databroker storage metrics and tracing (#1161)

* telmetry: add databroker storage metrics and tracing
This commit is contained in:
Travis Groth 2020-07-30 18:19:23 -04:00 committed by GitHub
parent 29fb96a955
commit 3c4513a91e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 255 additions and 15 deletions

View file

@ -0,0 +1,34 @@
package metrics
import (
"testing"
"github.com/gomodule/redigo/redis"
"go.opencensus.io/metric/metricdata"
)
func Test_AddRedisMetrics(t *testing.T) {
t.Parallel()
tests := []struct {
name string
stat redis.PoolStats
want int64
}{
{"redis_conns", redis.PoolStats{ActiveCount: 7}, 7},
{"redis_idle_conns", redis.PoolStats{IdleCount: 3}, 3},
{"redis_wait_count_total", redis.PoolStats{WaitCount: 2}, 2},
}
labelValues := []metricdata.LabelValue{
metricdata.NewLabelValue("redis"),
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
AddRedisMetrics(func() redis.PoolStats { return tt.stat })
testMetricRetrieval(registry.registry.Read(), t, labelValues, tt.want, tt.name)
})
}
}