From 404f8f617a44c2dbb00f4fb4f32ff79c6bbb1afc Mon Sep 17 00:00:00 2001 From: Sridhar Seshasayee Date: Tue, 17 Jul 2018 02:05:58 +0530 Subject: [PATCH 1/2] Integrate Opencensus grpc plugin within the grpc client and listener APIs. Include the ocgrpc client handler as a dial option within grpc.Dial(). This registers the ocgrpc client handler as a service. Provide the ocgrpc serverHandler to the grpc statsHandler when creating a new grpc server. Also, edit the Gopkg.toml file to update the following package versions for successful compilation, 1. "github.com/coreos/etcd": v3.2.9 -> v3.3.8 2. "github.com/golang/protobuf": v1.0.0 -> v1.1.0 3. "google.golang.org/grpc": v1.0.4 -> v1.13.0 Signed-off-by: Sridhar Seshasayee --- Gopkg.lock | 211 ++++++++++++++++++-------- Gopkg.toml | 6 +- glusterd2/servers/peerrpc/listener.go | 7 +- glusterd2/transaction/rpc-client.go | 10 +- 4 files changed, 163 insertions(+), 71 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 1bef76363..03057abff 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -5,7 +5,7 @@ branch = "master" name = "git.apache.org/thrift.git" packages = ["lib/go/thrift"] - revision = "f5f430df56871bc937950274b2c86681d3db6e59" + revision = "f12cacf56145e2c8f0d4429694fedf5453648089" source = "github.com/apache/thrift" [[projects]] @@ -18,13 +18,7 @@ branch = "master" name = "github.com/beorn7/perks" packages = ["quantile"] - revision = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9" - -[[projects]] - name = "github.com/boltdb/bolt" - packages = ["."] - revision = "583e8937c61f1af6513608ccc75c97b6abdf4ff9" - version = "v1.3.0" + revision = "3a771d992973f24aa725d07868b467d1ddfceafb" [[projects]] name = "github.com/cespare/xxhash" @@ -38,6 +32,11 @@ packages = ["."] revision = "30d10be492927e2dcae0089c374c455d42414fcb" +[[projects]] + name = "github.com/coreos/bbolt" + packages = ["."] + revision = "48ea1b39c25fc1bab3506fbc712ecbaa842c4d2d" + [[projects]] name = "github.com/coreos/etcd" packages = [ @@ -57,6 +56,7 @@ "etcdserver/api/etcdhttp", "etcdserver/api/v2http", "etcdserver/api/v2http/httptypes", + "etcdserver/api/v2v3", "etcdserver/api/v3client", "etcdserver/api/v3election", "etcdserver/api/v3election/v3electionpb", @@ -88,7 +88,6 @@ "pkg/idutil", "pkg/ioutil", "pkg/logutil", - "pkg/monotime", "pkg/netutil", "pkg/pathutil", "pkg/pbutil", @@ -110,8 +109,8 @@ "wal", "wal/walpb" ] - revision = "f1d7dd87da3e8feab4aaf675b8e29c6a5ed5f58b" - version = "v3.2.9" + revision = "33245c6b5b49130ca99280408fadfab01aac0e48" + version = "v3.3.8" [[projects]] name = "github.com/coreos/go-semver" @@ -122,8 +121,8 @@ [[projects]] name = "github.com/coreos/go-systemd" packages = ["journal"] - revision = "48702e0da86bd25e76cfef347e2adeb434a0d0a6" - version = "v14" + revision = "39ca1b05acc7ad1220e09f133283b8859a8b71ab" + version = "v17" [[projects]] name = "github.com/coreos/pkg" @@ -146,7 +145,8 @@ [[projects]] name = "github.com/fsnotify/fsnotify" packages = ["."] - revision = "a904159b9206978bb6d53fcc7a769e5cd726c737" + revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9" + version = "v1.4.7" [[projects]] name = "github.com/ghodss/yaml" @@ -156,30 +156,39 @@ [[projects]] name = "github.com/gogo/protobuf" - packages = ["proto"] - revision = "909568be09de550ed094403c2bf8a261b5bb730a" - version = "v0.3" + packages = [ + "gogoproto", + "proto", + "protoc-gen-gogo/descriptor" + ] + revision = "1adfc126b41513cc696b209667c8656ea7aac67c" + version = "v1.0.0" [[projects]] name = "github.com/golang/protobuf" packages = [ "jsonpb", "proto", - "ptypes/struct" + "ptypes", + "ptypes/any", + "ptypes/duration", + "ptypes/struct", + "ptypes/timestamp" ] - revision = "925541529c1fa6821df4e44ce2723319eb2be768" - version = "v1.0.0" + revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265" + version = "v1.1.0" [[projects]] + branch = "master" name = "github.com/google/btree" packages = ["."] - revision = "925471ac9e2131377a91e1595defec898166fe49" + revision = "e89373fe6b4a7413d7acd6da1725b83ef713e6e4" [[projects]] - branch = "master" name = "github.com/gorilla/context" packages = ["."] revision = "08b5f424b9271eedf6f9f0ce86cb9396ed337a42" + version = "v1.1.1" [[projects]] name = "github.com/gorilla/handlers" @@ -190,14 +199,20 @@ [[projects]] name = "github.com/gorilla/mux" packages = ["."] - revision = "53c1911da2b537f792e7cafcb446b05ffe33b996" - version = "v1.6.1" + revision = "e3702bed27f0d39777b0b37b664b6280e8ef8fbf" + version = "v1.6.2" + +[[projects]] + name = "github.com/gorilla/websocket" + packages = ["."] + revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b" + version = "v1.2.0" [[projects]] name = "github.com/grpc-ecosystem/go-grpc-prometheus" packages = ["."] - revision = "6b7015e65d366bf3f19b2b2a000a831940f0f7e0" - version = "v1.1" + revision = "c225b8c3b01faf2899099b768856a9e916e5087b" + version = "v1.2.0" [[projects]] name = "github.com/grpc-ecosystem/grpc-gateway" @@ -206,15 +221,16 @@ "runtime/internal", "utilities" ] - revision = "18d159699f2e83fc5bb9ef2f79465ca3f3122676" - version = "v1.2.0" + revision = "8cc3a55af3bcf171a1c23a90c4df9cf591706104" [[projects]] + branch = "master" name = "github.com/hashicorp/hcl" packages = [ ".", "hcl/ast", "hcl/parser", + "hcl/printer", "hcl/scanner", "hcl/strconv", "hcl/token", @@ -222,7 +238,7 @@ "json/scanner", "json/token" ] - revision = "630949a3c5fa3c613328e1b8256052cbc2327c9b" + revision = "ef8a98b0bbce4a65b5aa4c368430a80ddc533168" [[projects]] name = "github.com/inconshreveable/mousetrap" @@ -245,30 +261,32 @@ [[projects]] name = "github.com/magiconair/properties" packages = ["."] - revision = "b3b15ef068fd0b17ddf408a23669f20811d194d2" + revision = "c2353362d570a7bfa228149c62842019201cfb71" + version = "v1.8.0" [[projects]] - branch = "master" name = "github.com/mattn/go-runewidth" packages = ["."] - revision = "97311d9f7767e3d6f422ea06661bc2c7a19e8a5d" + revision = "9e777a8366cce605130a531d2cd6363d07ad7317" + version = "v0.0.2" [[projects]] - branch = "master" name = "github.com/matttproud/golang_protobuf_extensions" packages = ["pbutil"] revision = "c12348ce28de40eed0136aa2b644d0ee0650e56c" + version = "v1.0.1" [[projects]] + branch = "master" name = "github.com/mitchellh/mapstructure" packages = ["."] - revision = "db1efb556f84b25a0a13a04aad883943538ad2e0" + revision = "bb74f1db0675b241733089d5a1faa5dd8b0ef57b" [[projects]] branch = "master" name = "github.com/olekukonko/tablewriter" packages = ["."] - revision = "b8a9be070da40449e501c3c4730a889e42d87a9e" + revision = "d4647c9c7a84d847478d890b816b7d8b62b0b279" [[projects]] name = "github.com/pborman/uuid" @@ -296,7 +314,10 @@ [[projects]] name = "github.com/prometheus/client_golang" - packages = ["prometheus"] + packages = [ + "prometheus", + "prometheus/promhttp" + ] revision = "c5b7fccd204277076155f10851dad72b76a49317" version = "v0.8.0" @@ -304,24 +325,28 @@ branch = "master" name = "github.com/prometheus/client_model" packages = ["go"] - revision = "6f3806018612930941127f2a7c6c453ba2c527d2" + revision = "5c3871d89910bfb32f5fcab2aa4b9ec68e65a99f" [[projects]] + branch = "master" name = "github.com/prometheus/common" packages = [ "expfmt", "internal/bitbucket.org/ww/goautoneg", "model" ] - revision = "49fee292b27bfff7f354ee0f64e1bc4850462edf" + revision = "7600349dcfe1abd18d72d3a1770870d9800a7801" [[projects]] + branch = "master" name = "github.com/prometheus/procfs" packages = [ ".", + "internal/util", + "nfs", "xfs" ] - revision = "a1dba9ce8baed984a2495b658c82687f8157b98f" + revision = "ae68e2d4c00fed4943b5f6698d504a5fe083da8a" [[projects]] branch = "master" @@ -332,8 +357,14 @@ [[projects]] name = "github.com/sirupsen/logrus" packages = ["."] - revision = "f006c2ac4710855cf0f916dd6b77acf6b048dc6e" - version = "v1.0.3" + revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc" + version = "v1.0.5" + +[[projects]] + name = "github.com/soheilhy/cmux" + packages = ["."] + revision = "e09e9389d85d8492d313d73d1469c029e710623f" + version = "v0.1.4" [[projects]] name = "github.com/spf13/afero" @@ -341,35 +372,38 @@ ".", "mem" ] - revision = "9be650865eab0c12963d8753212f4f9c66cdcf12" + revision = "787d034dfe70e44075ccc060d346146ef53270ad" + version = "v1.1.1" [[projects]] name = "github.com/spf13/cast" packages = ["."] - revision = "f820543c3592e283e311a60d2a600a664e39f6f7" + revision = "8965335b8c7107321228e3e3702cab9832751bac" + version = "v1.2.0" [[projects]] name = "github.com/spf13/cobra" packages = ["."] - revision = "7b2c5ac9fc04fc5efafb60700713d4fa609b777b" - version = "v0.0.1" + revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" + version = "v0.0.3" [[projects]] + branch = "master" name = "github.com/spf13/jwalterweatherman" packages = ["."] - revision = "fa7ca7e836cf3a8bb4ebf799f472c12d7e903d66" + revision = "7c0cea34c8ece3fbeb2b27ab9b59511d360fb394" [[projects]] name = "github.com/spf13/pflag" packages = ["."] - revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" - version = "v1.0.0" + revision = "583c0c0531f06d5278b7d917446061adc344b5cd" + version = "v1.0.1" [[projects]] name = "github.com/spf13/viper" packages = ["."] - revision = "25b30aa063fc18e48662b86996252eabdcf2f0c7" - version = "v1.0.0" + revision = "b5e8006cbee93ec955a89ab31e0e3ce3204f3736" + version = "v1.0.2" [[projects]] name = "github.com/stretchr/testify" @@ -377,19 +411,26 @@ "assert", "require" ] - revision = "12b6f73e6084dad08a7c6e575284b177ecafbc71" - version = "v1.2.1" + revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" + version = "v1.2.2" [[projects]] name = "github.com/thejerf/suture" packages = ["."] - revision = "0ac47afae95ad5bc5184ed346bc945168e883f5d" - version = "v2.0.1" + revision = "f44dbcdd98cf42f65b78faac17288ad1ba2c041b" + version = "v2.0.3" + +[[projects]] + branch = "master" + name = "github.com/tmc/grpc-websocket-proxy" + packages = ["wsproxy"] + revision = "830351dc03c6f07d625727d5f993a463babb20e1" [[projects]] name = "github.com/ugorji/go" packages = ["codec"] - revision = "ded73eae5db7e7a0ef6f55aace87a2873c5d2b74" + revision = "b4c50a2b199d93b13dc15e78929cfb23bfdf21ab" + version = "v1.1.1" [[projects]] name = "github.com/xiang90/probing" @@ -404,6 +445,7 @@ "exporter/jaeger/internal/gen-go/jaeger", "internal", "internal/tagencoding", + "plugin/ocgrpc", "plugin/ochttp", "plugin/ochttp/propagation/b3", "stats", @@ -418,27 +460,28 @@ version = "v0.11.0" [[projects]] + branch = "master" name = "golang.org/x/crypto" packages = [ "bcrypt", "blowfish", "ssh/terminal" ] - revision = "9419663f5a44be8b34ca85f08abc5fe1be11f8a3" + revision = "a49355c7e3f8fe157a85be2f77e6e269a0f89602" [[projects]] branch = "master" name = "golang.org/x/net" packages = [ "context", + "http/httpguts", "http2", "http2/hpack", "idna", "internal/timeseries", - "lex/httplex", "trace" ] - revision = "f5dfe339be1d06f81b22525fe34671ee7d2c8904" + revision = "d0887baf81f4598189d4e12a37c6da86f0bba4d0" [[projects]] branch = "master" @@ -453,14 +496,19 @@ "unix", "windows" ] - revision = "37707fdb30a5b38865cfb95e5aab41707daec7fd" + revision = "1b2967e3c290b7c545b3db0deeda16e9be4f98a2" [[projects]] name = "golang.org/x/text" packages = [ + "collate", + "collate/build", + "internal/colltab", "internal/gen", + "internal/tag", "internal/triegen", "internal/ucd", + "language", "secure/bidirule", "transform", "unicode/bidi", @@ -468,39 +516,70 @@ "unicode/norm", "unicode/rangetable" ] - revision = "0ad425fe45e885577bef05dc1c50f72e33188b16" + revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" + version = "v0.3.0" + +[[projects]] + branch = "master" + name = "golang.org/x/time" + packages = ["rate"] + revision = "fbb02b2291d28baffd63558aa44b4b56f178d650" [[projects]] branch = "master" name = "google.golang.org/api" packages = ["support/bundler"] - revision = "2eea9ba0a3d94f6ab46508083e299a00bbbc65f6" + revision = "781db45e5b94469718b0c615037e76333cd050e3" + +[[projects]] + branch = "master" + name = "google.golang.org/genproto" + packages = ["googleapis/rpc/status"] + revision = "e92b116572682a5b432ddd840aeaba2a559eeff1" [[projects]] name = "google.golang.org/grpc" packages = [ ".", + "balancer", + "balancer/base", + "balancer/roundrobin", "codes", + "connectivity", "credentials", + "encoding", + "encoding/proto", "grpclog", + "health", + "health/grpc_health_v1", "internal", + "internal/backoff", + "internal/channelz", + "internal/grpcrand", + "keepalive", "metadata", "naming", "peer", + "resolver", + "resolver/dns", + "resolver/passthrough", + "stats", + "status", + "tap", "transport" ] - revision = "777daa17ff9b5daef1cfdf915088a2ada3332bf0" - version = "v1.0.4" + revision = "168a6198bcb0ef175f7dacec0b8691fc141dc9b8" + version = "v1.13.0" [[projects]] - branch = "v2" name = "gopkg.in/yaml.v2" packages = ["."] - revision = "d670f9405373e636a5a2765eea47fac0c9bc91a4" + revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183" + version = "v2.2.1" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "4349628706ad8a7873c76ab4f36fed3e6656efaeca63db11754957dfe75b22a0" + inputs-digest = "6c5bb30b3fc2f361b83a245f51cd824ba49f4e46a125ca38702c8b561cd5dd83" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 1bab28d52..7700bdd15 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -4,7 +4,7 @@ [[constraint]] name = "github.com/coreos/etcd" - version = "3.2.9" + version = "3.3.8" [[constraint]] name = "github.com/coreos/pkg" @@ -16,7 +16,7 @@ [[constraint]] name = "github.com/golang/protobuf" - version = "~1.0.0" + version = "~1.1.0" [[constraint]] name = "github.com/gorilla/handlers" @@ -84,7 +84,7 @@ [[constraint]] name = "google.golang.org/grpc" - version = "^1.0.4" + version = "^1.13.0" [[constraint]] name = "github.com/asaskevich/govalidator" diff --git a/glusterd2/servers/peerrpc/listener.go b/glusterd2/servers/peerrpc/listener.go index 79aeb22fb..d598199a1 100644 --- a/glusterd2/servers/peerrpc/listener.go +++ b/glusterd2/servers/peerrpc/listener.go @@ -6,6 +6,8 @@ import ( log "github.com/sirupsen/logrus" config "github.com/spf13/viper" + "go.opencensus.io/plugin/ocgrpc" + "go.opencensus.io/trace" "google.golang.org/grpc" ) @@ -18,7 +20,10 @@ type Server struct { // New returns a new peerrpc.Server with registered gRPC services func New() *Server { s := &Server{ - grpc.NewServer(), + grpc.NewServer(grpc.StatsHandler(&ocgrpc.ServerHandler{ + StartOptions: trace.StartOptions{ + Sampler: trace.AlwaysSample(), + }})), } registerServices(s.server) diff --git a/glusterd2/transaction/rpc-client.go b/glusterd2/transaction/rpc-client.go index fa5546fcb..5a5b8a2d0 100644 --- a/glusterd2/transaction/rpc-client.go +++ b/glusterd2/transaction/rpc-client.go @@ -9,6 +9,8 @@ import ( "github.com/pborman/uuid" log "github.com/sirupsen/logrus" + "go.opencensus.io/plugin/ocgrpc" + "go.opencensus.io/trace" netctx "golang.org/x/net/context" "google.golang.org/grpc" ) @@ -35,7 +37,13 @@ func runStepOn(step string, node uuid.UUID, c TxnCtx) error { return err } - conn, err = grpc.Dial(remote, grpc.WithInsecure()) + conn, err = grpc.Dial(remote, + grpc.WithStatsHandler(&ocgrpc.ClientHandler{ + StartOptions: trace.StartOptions{ + Sampler: trace.AlwaysSample(), + }}), + grpc.WithInsecure(), + ) if err == nil && conn != nil { logger.WithFields(log.Fields{ "remote": remote, From 13690fd08cd9e93a3c8ebe4f821560d13d46d4ea Mon Sep 17 00:00:00 2001 From: Sridhar Seshasayee Date: Tue, 24 Jul 2018 12:15:31 +0530 Subject: [PATCH 2/2] Pass original context to trace volume create steps across grpc nodes. Pass the original context to the runStepOn() function so that it can be used by the opensensus grpc plugin to trace the calls on other nodes in the gluster cluster. Also, append the requestID to the span info in addition to the associated function name so that the operation can be identified on the tracing UI application. Signed-off-by: Sridhar Seshasayee --- glusterd2/transaction/rpc-client.go | 4 ++-- glusterd2/transaction/rpc-service.go | 8 ++++++++ glusterd2/transaction/step.go | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/glusterd2/transaction/rpc-client.go b/glusterd2/transaction/rpc-client.go index 5a5b8a2d0..373ac901c 100644 --- a/glusterd2/transaction/rpc-client.go +++ b/glusterd2/transaction/rpc-client.go @@ -16,7 +16,7 @@ import ( ) // runStepOn will run the step on the specified node -func runStepOn(step string, node uuid.UUID, c TxnCtx) error { +func runStepOn(origCtx netctx.Context, step string, node uuid.UUID, c TxnCtx) error { // TODO: I'm creating connections on demand. This should be changed so that // we have long term connections. p, err := peer.GetPeerF(node.String()) @@ -73,7 +73,7 @@ func runStepOn(step string, node uuid.UUID, c TxnCtx) error { var rsp *TxnStepResp - rsp, err = client.RunStep(netctx.TODO(), req) + rsp, err = client.RunStep(origCtx, req) if err != nil { logger.WithFields(log.Fields{ "error": err, diff --git a/glusterd2/transaction/rpc-service.go b/glusterd2/transaction/rpc-service.go index e040d7d98..bec886871 100644 --- a/glusterd2/transaction/rpc-service.go +++ b/glusterd2/transaction/rpc-service.go @@ -7,6 +7,7 @@ import ( "github.com/gluster/glusterd2/glusterd2/servers/peerrpc" log "github.com/sirupsen/logrus" + "go.opencensus.io/trace" "golang.org/x/net/context" "google.golang.org/grpc" ) @@ -37,6 +38,13 @@ func (p *txnSvc) RunStep(rpcCtx context.Context, req *TxnStepReq) (*TxnStepResp, logger = ctx.Logger().WithField("stepfunc", req.StepFunc) logger.Debug("RunStep request received") + if rpcCtx != nil { + reqID := ctx.GetTxnReqID() + spanName := req.StepFunc + " ReqID:" + reqID + _, span := trace.StartSpan(rpcCtx, spanName) + defer span.End() + } + f, ok = getStepFunc(req.StepFunc) if !ok { err = errors.New("step function not found in registry") diff --git a/glusterd2/transaction/step.go b/glusterd2/transaction/step.go index 2c8246c94..da2441377 100644 --- a/glusterd2/transaction/step.go +++ b/glusterd2/transaction/step.go @@ -139,7 +139,7 @@ func runStepFuncOnNode(origCtx context.Context, stepName string, ctx TxnCtx, nod err = runStepFuncLocally(origCtx, stepName, ctx) } else { // remote node - err = runStepOn(stepName, node, ctx) + err = runStepOn(origCtx, stepName, node, ctx) } respCh <- stepPeerResp{node, err}