clientv3: add DialOptions to config

Removes strict prometheus dependency.

Fixes #7058
This commit is contained in:
Anthony Romano
2017-02-03 11:05:59 -08:00
parent 4203c766fb
commit 8c43bd06a0
4 changed files with 66 additions and 18 deletions

View File

@ -29,8 +29,10 @@ import (
"github.com/coreos/etcd/pkg/testutil"
"github.com/coreos/etcd/pkg/transport"
grpcprom "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
func TestV3ClientMetrics(t *testing.T) {
@ -66,20 +68,26 @@ func TestV3ClientMetrics(t *testing.T) {
clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
defer clus.Terminate(t)
client := clus.Client(0)
cfg := clientv3.Config{
Endpoints: []string{clus.Members[0].GRPCAddr()},
DialOptions: []grpc.DialOption{
grpc.WithUnaryInterceptor(grpcprom.UnaryClientInterceptor),
grpc.WithStreamInterceptor(grpcprom.StreamClientInterceptor),
},
}
cli, cerr := clientv3.New(cfg)
if cerr != nil {
t.Fatal(cerr)
}
defer cli.Close()
w := clientv3.NewWatcher(client)
defer w.Close()
kv := clientv3.NewKV(client)
wc := w.Watch(context.Background(), "foo")
wc := cli.Watch(context.Background(), "foo")
wBefore := sumCountersForMetricAndLabels(t, url, "grpc_client_msg_received_total", "Watch", "bidi_stream")
pBefore := sumCountersForMetricAndLabels(t, url, "grpc_client_started_total", "Put", "unary")
_, err = kv.Put(context.Background(), "foo", "bar")
_, err = cli.Put(context.Background(), "foo", "bar")
if err != nil {
t.Errorf("Error putting value in key store")
}