|
@@ -29,8 +29,10 @@ import (
|
|
|
"github.com/coreos/etcd/pkg/testutil"
|
|
"github.com/coreos/etcd/pkg/testutil"
|
|
|
"github.com/coreos/etcd/pkg/transport"
|
|
"github.com/coreos/etcd/pkg/transport"
|
|
|
|
|
|
|
|
|
|
+ grpcprom "github.com/grpc-ecosystem/go-grpc-prometheus"
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
"golang.org/x/net/context"
|
|
"golang.org/x/net/context"
|
|
|
|
|
+ "google.golang.org/grpc"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
func TestV3ClientMetrics(t *testing.T) {
|
|
func TestV3ClientMetrics(t *testing.T) {
|
|
@@ -66,20 +68,26 @@ func TestV3ClientMetrics(t *testing.T) {
|
|
|
clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
|
|
clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
|
|
|
defer clus.Terminate(t)
|
|
defer clus.Terminate(t)
|
|
|
|
|
|
|
|
- client := clus.Client(0)
|
|
|
|
|
-
|
|
|
|
|
- w := clientv3.NewWatcher(client)
|
|
|
|
|
- defer w.Close()
|
|
|
|
|
-
|
|
|
|
|
- kv := clientv3.NewKV(client)
|
|
|
|
|
|
|
+ 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()
|
|
|
|
|
|
|
|
- wc := w.Watch(context.Background(), "foo")
|
|
|
|
|
|
|
+ wc := cli.Watch(context.Background(), "foo")
|
|
|
|
|
|
|
|
wBefore := sumCountersForMetricAndLabels(t, url, "grpc_client_msg_received_total", "Watch", "bidi_stream")
|
|
wBefore := sumCountersForMetricAndLabels(t, url, "grpc_client_msg_received_total", "Watch", "bidi_stream")
|
|
|
|
|
|
|
|
pBefore := sumCountersForMetricAndLabels(t, url, "grpc_client_started_total", "Put", "unary")
|
|
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 {
|
|
if err != nil {
|
|
|
t.Errorf("Error putting value in key store")
|
|
t.Errorf("Error putting value in key store")
|
|
|
}
|
|
}
|