mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Opencensus grpc wrappers for Jaeger traces (#1514)
* Adding oc server handler option into pure_runner Adding opencensus ocgrpc.ServerHandler into pr.gRPCOptions * Adding oc client handler for static_pool Adding opencensus client handler ocgrpc.ClientHandler for traces into static_pool.go * fixing gofmt format issues * adding ocgrpc plugin * Revendoring
This commit is contained in:
committed by
Reed Allman
parent
90bdfc479f
commit
95294fd903
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/fnproject/fn/grpcutil"
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.opencensus.io/plugin/ocgrpc"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials"
|
||||
@@ -1171,6 +1172,7 @@ func NewPureRunner(cancel context.CancelFunc, addr string, options ...PureRunner
|
||||
|
||||
pr.gRPCOptions = append(pr.gRPCOptions, grpc.StreamInterceptor(grpcutil.RIDStreamServerInterceptor))
|
||||
pr.gRPCOptions = append(pr.gRPCOptions, grpc.UnaryInterceptor(grpcutil.RIDUnaryServerInterceptor))
|
||||
pr.gRPCOptions = append(pr.gRPCOptions, grpc.StatsHandler(&ocgrpc.ServerHandler{}))
|
||||
|
||||
if pr.creds != nil {
|
||||
pr.gRPCOptions = append(pr.gRPCOptions, grpc.Creds(pr.creds))
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
pool "github.com/fnproject/fn/api/runnerpool"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.opencensus.io/plugin/ocgrpc"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -22,6 +23,7 @@ func DefaultStaticRunnerPool(runnerAddresses []string) pool.RunnerPool {
|
||||
func NewStaticRunnerPool(runnerAddresses []string, tlsConf *tls.Config, dialOpts ...grpc.DialOption) pool.RunnerPool {
|
||||
logrus.WithField("runners", runnerAddresses).Info("Starting static runner pool")
|
||||
var runners []pool.Runner
|
||||
dialOpts = append(dialOpts, grpc.WithStatsHandler(new(ocgrpc.ClientHandler)))
|
||||
for _, addr := range runnerAddresses {
|
||||
r, err := NewgRPCRunner(addr, tlsConf, dialOpts...)
|
||||
if err != nil {
|
||||
|
||||
16
go.mod
16
go.mod
@@ -3,6 +3,8 @@ module github.com/fnproject/fn
|
||||
replace cloud.google.com/go => github.com/google/go-cloud v0.4.1-0.20181025204856-f29236cc19de
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.34.0 // indirect
|
||||
git.apache.org/thrift.git v0.0.0-20181218151757-9b75e4fe745a // indirect
|
||||
github.com/coreos/go-semver v0.2.1-0.20180108230905-e214231b295a
|
||||
github.com/dchest/siphash v1.2.0
|
||||
github.com/fnproject/fdk-go v0.0.0-20181025170718-26ed643bea68
|
||||
@@ -13,8 +15,10 @@ require (
|
||||
github.com/gin-gonic/gin v1.3.0
|
||||
github.com/go-sql-driver/mysql v1.4.0
|
||||
github.com/golang/groupcache v0.0.0-20180924190550-6f2cf27854a4
|
||||
github.com/golang/mock v1.2.0 // indirect
|
||||
github.com/golang/protobuf v1.3.1
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.6.2 // indirect
|
||||
github.com/jmoiron/sqlx v1.2.0
|
||||
github.com/json-iterator/go v1.1.5 // indirect
|
||||
github.com/leanovate/gopter v0.2.2
|
||||
@@ -26,15 +30,19 @@ require (
|
||||
github.com/openzipkin/zipkin-go v0.1.3
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/prometheus/client_golang v0.9.2
|
||||
github.com/prometheus/common v0.0.0-20181218105931-67670fe90761 // indirect
|
||||
github.com/sirupsen/logrus v1.3.0
|
||||
github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f // indirect
|
||||
go.opencensus.io v0.19.0
|
||||
golang.org/x/net v0.0.0-20181217023233-e147a9138326
|
||||
golang.org/x/sys v0.0.0-20190310054646-10058d7d4faa
|
||||
go.opencensus.io v0.22.1-0.20190619184131-df42942ad08f
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09
|
||||
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 // indirect
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2
|
||||
google.golang.org/grpc v1.17.0
|
||||
google.golang.org/api v0.0.0-20181220000619-583d854617af // indirect
|
||||
google.golang.org/grpc v1.20.1
|
||||
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
|
||||
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
|
||||
gopkg.in/yaml.v2 v2.2.2 // indirect
|
||||
)
|
||||
|
||||
replace (
|
||||
|
||||
26
go.sum
26
go.sum
@@ -3,6 +3,7 @@ contrib.go.opencensus.io/exporter/stackdriver v0.6.0/go.mod h1:QeFzMJDAw8TXt5+aR
|
||||
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
|
||||
git.apache.org/thrift.git v0.0.0-20181218151757-9b75e4fe745a h1:GnKpWvJXysBGdcWMEibN//UeRRJeLDUgsXjKXjagFLg=
|
||||
git.apache.org/thrift.git v0.0.0-20181218151757-9b75e4fe745a/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20181009230506-ac834ce67862/go.mod h1:aJ4qN3TfrelA6NZ6AXsXRfmEVaYin3EDbSPJrKS8OXo=
|
||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
|
||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
|
||||
@@ -85,6 +86,7 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z
|
||||
github.com/google/go-cloud v0.4.1-0.20181025204856-f29236cc19de/go.mod h1:zIXR03PyBRhLPWwHYkj98zq25qmUVwn1NL8GZB/+lF8=
|
||||
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
@@ -102,6 +104,8 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.5.1/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.6.2 h1:8KyC64BiO8ndiGHY5DlFWWdangUPC9QHPakFRre/Ud0=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.6.2/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
|
||||
github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/ijc/Gotty v0.0.0-20170406111628-a8b993ba6abd h1:anPrsicrIi2ColgWTVPk+TrN42hJIWlfPHSBP9S0ZkM=
|
||||
github.com/ijc/Gotty v0.0.0-20170406111628-a8b993ba6abd/go.mod h1:3LVOLeyx9XVvwPgrt2be44XgSqndprz1G18rSk8KD84=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
@@ -197,6 +201,8 @@ go.opencensus.io v0.15.0/go.mod h1:UffZAU+4sDEINUGP/B7UfBBkq4fqLu9zXAX7ke6CHW0=
|
||||
go.opencensus.io v0.17.0/go.mod h1:mp1VrMQxhlqqDpKvH4UcQUa4YwlzNmymAjPrDdfxNpI=
|
||||
go.opencensus.io v0.19.0 h1:+jrnNy8MR4GZXvwF9PEuSyHxA4NaTf6601oNRwCSXq0=
|
||||
go.opencensus.io v0.19.0/go.mod h1:AYeH0+ZxYyghG8diqaaIq/9P3VgCCt5GF2ldCY4dkFg=
|
||||
go.opencensus.io v0.22.1-0.20190619184131-df42942ad08f h1:2BylqR1hTQ5EyJh5qkVmD4fH8daS+/iH4TR9zIBHnqM=
|
||||
go.opencensus.io v0.22.1-0.20190619184131-df42942ad08f/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4=
|
||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
|
||||
@@ -209,9 +215,12 @@ golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e h1:IzypfodbhbnViNUO/MEh0F
|
||||
golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -220,6 +229,9 @@ golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73r
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181217023233-e147a9138326 h1:iCzOf0xz39Tstp+Tu/WwyGjUXCk34QhQORRxBeXXTA4=
|
||||
golang.org/x/net v0.0.0-20181217023233-e147a9138326/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@@ -228,6 +240,7 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTm
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -238,14 +251,20 @@ golang.org/x/sys v0.0.0-20181218192612-074acd46bca6/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190310054646-10058d7d4faa h1:lqti/xP+yD/6zH5TqEwx2MilNIJY5Vbc6Qr8J3qyPIQ=
|
||||
golang.org/x/sys v0.0.0-20190310054646-10058d7d4faa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181017214349-06f26fdaaa28/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181219222714-6e267b5cc78e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
|
||||
google.golang.org/api v0.0.0-20181017004218-3f6e8463aa1d/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
|
||||
google.golang.org/api v0.0.0-20181220000619-583d854617af h1:iQMS7JKv/0w/iiWf1M49Cg3dmOkBoBZT5KheqPDpaac=
|
||||
@@ -254,16 +273,22 @@ google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9Ywl
|
||||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.3.0 h1:FBSsiFRMz3LBeXIomRnVzrQwSDj4ibvcRexLG0LZGQk=
|
||||
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20181016170114-94acd270e44e/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20181219182458-5a97ab628bfb h1:dQshZyyJ5W/Xk8myF4GKBak1pZW6EywJuQ8+44EQhGA=
|
||||
google.golang.org/genproto v0.0.0-20181219182458-5a97ab628bfb/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb h1:i1Ppqkc3WQXikh8bXiwHqAN5Rv3/qDCcRk0/Otx73BY=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||||
google.golang.org/grpc v1.15.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
|
||||
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
|
||||
google.golang.org/grpc v1.17.0 h1:TRJYBgMclJvGYn2rIMjj+h9KtMt5r1Ij7ODVRIZkwhk=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
@@ -281,3 +306,4 @@ gotest.tools v2.1.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
||||
56
vendor/go.opencensus.io/plugin/ocgrpc/client.go
generated
vendored
Normal file
56
vendor/go.opencensus.io/plugin/ocgrpc/client.go
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright 2018, OpenCensus Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ocgrpc
|
||||
|
||||
import (
|
||||
"go.opencensus.io/trace"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"google.golang.org/grpc/stats"
|
||||
)
|
||||
|
||||
// ClientHandler implements a gRPC stats.Handler for recording OpenCensus stats and
|
||||
// traces. Use with gRPC clients only.
|
||||
type ClientHandler struct {
|
||||
// StartOptions allows configuring the StartOptions used to create new spans.
|
||||
//
|
||||
// StartOptions.SpanKind will always be set to trace.SpanKindClient
|
||||
// for spans started by this handler.
|
||||
StartOptions trace.StartOptions
|
||||
}
|
||||
|
||||
// HandleConn exists to satisfy gRPC stats.Handler.
|
||||
func (c *ClientHandler) HandleConn(ctx context.Context, cs stats.ConnStats) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
// TagConn exists to satisfy gRPC stats.Handler.
|
||||
func (c *ClientHandler) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context {
|
||||
// no-op
|
||||
return ctx
|
||||
}
|
||||
|
||||
// HandleRPC implements per-RPC tracing and stats instrumentation.
|
||||
func (c *ClientHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
|
||||
traceHandleRPC(ctx, rs)
|
||||
statsHandleRPC(ctx, rs)
|
||||
}
|
||||
|
||||
// TagRPC implements per-RPC context management.
|
||||
func (c *ClientHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context {
|
||||
ctx = c.traceTagRPC(ctx, rti)
|
||||
ctx = c.statsTagRPC(ctx, rti)
|
||||
return ctx
|
||||
}
|
||||
107
vendor/go.opencensus.io/plugin/ocgrpc/client_metrics.go
generated
vendored
Normal file
107
vendor/go.opencensus.io/plugin/ocgrpc/client_metrics.go
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
// Copyright 2017, OpenCensus Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package ocgrpc
|
||||
|
||||
import (
|
||||
"go.opencensus.io/stats"
|
||||
"go.opencensus.io/stats/view"
|
||||
"go.opencensus.io/tag"
|
||||
)
|
||||
|
||||
// The following variables are measures are recorded by ClientHandler:
|
||||
var (
|
||||
ClientSentMessagesPerRPC = stats.Int64("grpc.io/client/sent_messages_per_rpc", "Number of messages sent in the RPC (always 1 for non-streaming RPCs).", stats.UnitDimensionless)
|
||||
ClientSentBytesPerRPC = stats.Int64("grpc.io/client/sent_bytes_per_rpc", "Total bytes sent across all request messages per RPC.", stats.UnitBytes)
|
||||
ClientReceivedMessagesPerRPC = stats.Int64("grpc.io/client/received_messages_per_rpc", "Number of response messages received per RPC (always 1 for non-streaming RPCs).", stats.UnitDimensionless)
|
||||
ClientReceivedBytesPerRPC = stats.Int64("grpc.io/client/received_bytes_per_rpc", "Total bytes received across all response messages per RPC.", stats.UnitBytes)
|
||||
ClientRoundtripLatency = stats.Float64("grpc.io/client/roundtrip_latency", "Time between first byte of request sent to last byte of response received, or terminal error.", stats.UnitMilliseconds)
|
||||
ClientServerLatency = stats.Float64("grpc.io/client/server_latency", `Propagated from the server and should have the same value as "grpc.io/server/latency".`, stats.UnitMilliseconds)
|
||||
)
|
||||
|
||||
// Predefined views may be registered to collect data for the above measures.
|
||||
// As always, you may also define your own custom views over measures collected by this
|
||||
// package. These are declared as a convenience only; none are registered by
|
||||
// default.
|
||||
var (
|
||||
ClientSentBytesPerRPCView = &view.View{
|
||||
Measure: ClientSentBytesPerRPC,
|
||||
Name: "grpc.io/client/sent_bytes_per_rpc",
|
||||
Description: "Distribution of bytes sent per RPC, by method.",
|
||||
TagKeys: []tag.Key{KeyClientMethod},
|
||||
Aggregation: DefaultBytesDistribution,
|
||||
}
|
||||
|
||||
ClientReceivedBytesPerRPCView = &view.View{
|
||||
Measure: ClientReceivedBytesPerRPC,
|
||||
Name: "grpc.io/client/received_bytes_per_rpc",
|
||||
Description: "Distribution of bytes received per RPC, by method.",
|
||||
TagKeys: []tag.Key{KeyClientMethod},
|
||||
Aggregation: DefaultBytesDistribution,
|
||||
}
|
||||
|
||||
ClientRoundtripLatencyView = &view.View{
|
||||
Measure: ClientRoundtripLatency,
|
||||
Name: "grpc.io/client/roundtrip_latency",
|
||||
Description: "Distribution of round-trip latency, by method.",
|
||||
TagKeys: []tag.Key{KeyClientMethod},
|
||||
Aggregation: DefaultMillisecondsDistribution,
|
||||
}
|
||||
|
||||
ClientCompletedRPCsView = &view.View{
|
||||
Measure: ClientRoundtripLatency,
|
||||
Name: "grpc.io/client/completed_rpcs",
|
||||
Description: "Count of RPCs by method and status.",
|
||||
TagKeys: []tag.Key{KeyClientMethod, KeyClientStatus},
|
||||
Aggregation: view.Count(),
|
||||
}
|
||||
|
||||
ClientSentMessagesPerRPCView = &view.View{
|
||||
Measure: ClientSentMessagesPerRPC,
|
||||
Name: "grpc.io/client/sent_messages_per_rpc",
|
||||
Description: "Distribution of sent messages count per RPC, by method.",
|
||||
TagKeys: []tag.Key{KeyClientMethod},
|
||||
Aggregation: DefaultMessageCountDistribution,
|
||||
}
|
||||
|
||||
ClientReceivedMessagesPerRPCView = &view.View{
|
||||
Measure: ClientReceivedMessagesPerRPC,
|
||||
Name: "grpc.io/client/received_messages_per_rpc",
|
||||
Description: "Distribution of received messages count per RPC, by method.",
|
||||
TagKeys: []tag.Key{KeyClientMethod},
|
||||
Aggregation: DefaultMessageCountDistribution,
|
||||
}
|
||||
|
||||
ClientServerLatencyView = &view.View{
|
||||
Measure: ClientServerLatency,
|
||||
Name: "grpc.io/client/server_latency",
|
||||
Description: "Distribution of server latency as viewed by client, by method.",
|
||||
TagKeys: []tag.Key{KeyClientMethod},
|
||||
Aggregation: DefaultMillisecondsDistribution,
|
||||
}
|
||||
)
|
||||
|
||||
// DefaultClientViews are the default client views provided by this package.
|
||||
var DefaultClientViews = []*view.View{
|
||||
ClientSentBytesPerRPCView,
|
||||
ClientReceivedBytesPerRPCView,
|
||||
ClientRoundtripLatencyView,
|
||||
ClientCompletedRPCsView,
|
||||
}
|
||||
|
||||
// TODO(jbd): Add roundtrip_latency, uncompressed_request_bytes, uncompressed_response_bytes, request_count, response_count.
|
||||
// TODO(acetechnologist): This is temporary and will need to be replaced by a
|
||||
// mechanism to load these defaults from a common repository/config shared by
|
||||
// all supported languages. Likely a serialized protobuf of these defaults.
|
||||
49
vendor/go.opencensus.io/plugin/ocgrpc/client_stats_handler.go
generated
vendored
Normal file
49
vendor/go.opencensus.io/plugin/ocgrpc/client_stats_handler.go
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2017, OpenCensus Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package ocgrpc
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.opencensus.io/tag"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/stats"
|
||||
)
|
||||
|
||||
// statsTagRPC gets the tag.Map populated by the application code, serializes
|
||||
// its tags into the GRPC metadata in order to be sent to the server.
|
||||
func (h *ClientHandler) statsTagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
|
||||
startTime := time.Now()
|
||||
if info == nil {
|
||||
if grpclog.V(2) {
|
||||
grpclog.Infof("clientHandler.TagRPC called with nil info.", info.FullMethodName)
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
d := &rpcData{
|
||||
startTime: startTime,
|
||||
method: info.FullMethodName,
|
||||
}
|
||||
ts := tag.FromContext(ctx)
|
||||
if ts != nil {
|
||||
encoded := tag.Encode(ts)
|
||||
ctx = stats.SetTags(ctx, encoded)
|
||||
}
|
||||
|
||||
return context.WithValue(ctx, rpcDataKey, d)
|
||||
}
|
||||
19
vendor/go.opencensus.io/plugin/ocgrpc/doc.go
generated
vendored
Normal file
19
vendor/go.opencensus.io/plugin/ocgrpc/doc.go
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright 2017, OpenCensus Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package ocgrpc contains OpenCensus stats and trace
|
||||
// integrations for gRPC.
|
||||
//
|
||||
// Use ServerHandler for servers and ClientHandler for clients.
|
||||
package ocgrpc // import "go.opencensus.io/plugin/ocgrpc"
|
||||
80
vendor/go.opencensus.io/plugin/ocgrpc/server.go
generated
vendored
Normal file
80
vendor/go.opencensus.io/plugin/ocgrpc/server.go
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
// Copyright 2018, OpenCensus Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ocgrpc
|
||||
|
||||
import (
|
||||
"go.opencensus.io/trace"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"google.golang.org/grpc/stats"
|
||||
)
|
||||
|
||||
// ServerHandler implements gRPC stats.Handler recording OpenCensus stats and
|
||||
// traces. Use with gRPC servers.
|
||||
//
|
||||
// When installed (see Example), tracing metadata is read from inbound RPCs
|
||||
// by default. If no tracing metadata is present, or if the tracing metadata is
|
||||
// present but the SpanContext isn't sampled, then a new trace may be started
|
||||
// (as determined by Sampler).
|
||||
type ServerHandler struct {
|
||||
// IsPublicEndpoint may be set to true to always start a new trace around
|
||||
// each RPC. Any SpanContext in the RPC metadata will be added as a linked
|
||||
// span instead of making it the parent of the span created around the
|
||||
// server RPC.
|
||||
//
|
||||
// Be aware that if you leave this false (the default) on a public-facing
|
||||
// server, callers will be able to send tracing metadata in gRPC headers
|
||||
// and trigger traces in your backend.
|
||||
IsPublicEndpoint bool
|
||||
|
||||
// StartOptions to use for to spans started around RPCs handled by this server.
|
||||
//
|
||||
// These will apply even if there is tracing metadata already
|
||||
// present on the inbound RPC but the SpanContext is not sampled. This
|
||||
// ensures that each service has some opportunity to be traced. If you would
|
||||
// like to not add any additional traces for this gRPC service, set:
|
||||
//
|
||||
// StartOptions.Sampler = trace.ProbabilitySampler(0.0)
|
||||
//
|
||||
// StartOptions.SpanKind will always be set to trace.SpanKindServer
|
||||
// for spans started by this handler.
|
||||
StartOptions trace.StartOptions
|
||||
}
|
||||
|
||||
var _ stats.Handler = (*ServerHandler)(nil)
|
||||
|
||||
// HandleConn exists to satisfy gRPC stats.Handler.
|
||||
func (s *ServerHandler) HandleConn(ctx context.Context, cs stats.ConnStats) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
// TagConn exists to satisfy gRPC stats.Handler.
|
||||
func (s *ServerHandler) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context {
|
||||
// no-op
|
||||
return ctx
|
||||
}
|
||||
|
||||
// HandleRPC implements per-RPC tracing and stats instrumentation.
|
||||
func (s *ServerHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
|
||||
traceHandleRPC(ctx, rs)
|
||||
statsHandleRPC(ctx, rs)
|
||||
}
|
||||
|
||||
// TagRPC implements per-RPC context management.
|
||||
func (s *ServerHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context {
|
||||
ctx = s.traceTagRPC(ctx, rti)
|
||||
ctx = s.statsTagRPC(ctx, rti)
|
||||
return ctx
|
||||
}
|
||||
97
vendor/go.opencensus.io/plugin/ocgrpc/server_metrics.go
generated
vendored
Normal file
97
vendor/go.opencensus.io/plugin/ocgrpc/server_metrics.go
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
// Copyright 2017, OpenCensus Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package ocgrpc
|
||||
|
||||
import (
|
||||
"go.opencensus.io/stats"
|
||||
"go.opencensus.io/stats/view"
|
||||
"go.opencensus.io/tag"
|
||||
)
|
||||
|
||||
// The following variables are measures are recorded by ServerHandler:
|
||||
var (
|
||||
ServerReceivedMessagesPerRPC = stats.Int64("grpc.io/server/received_messages_per_rpc", "Number of messages received in each RPC. Has value 1 for non-streaming RPCs.", stats.UnitDimensionless)
|
||||
ServerReceivedBytesPerRPC = stats.Int64("grpc.io/server/received_bytes_per_rpc", "Total bytes received across all messages per RPC.", stats.UnitBytes)
|
||||
ServerSentMessagesPerRPC = stats.Int64("grpc.io/server/sent_messages_per_rpc", "Number of messages sent in each RPC. Has value 1 for non-streaming RPCs.", stats.UnitDimensionless)
|
||||
ServerSentBytesPerRPC = stats.Int64("grpc.io/server/sent_bytes_per_rpc", "Total bytes sent in across all response messages per RPC.", stats.UnitBytes)
|
||||
ServerLatency = stats.Float64("grpc.io/server/server_latency", "Time between first byte of request received to last byte of response sent, or terminal error.", stats.UnitMilliseconds)
|
||||
)
|
||||
|
||||
// TODO(acetechnologist): This is temporary and will need to be replaced by a
|
||||
// mechanism to load these defaults from a common repository/config shared by
|
||||
// all supported languages. Likely a serialized protobuf of these defaults.
|
||||
|
||||
// Predefined views may be registered to collect data for the above measures.
|
||||
// As always, you may also define your own custom views over measures collected by this
|
||||
// package. These are declared as a convenience only; none are registered by
|
||||
// default.
|
||||
var (
|
||||
ServerReceivedBytesPerRPCView = &view.View{
|
||||
Name: "grpc.io/server/received_bytes_per_rpc",
|
||||
Description: "Distribution of received bytes per RPC, by method.",
|
||||
Measure: ServerReceivedBytesPerRPC,
|
||||
TagKeys: []tag.Key{KeyServerMethod},
|
||||
Aggregation: DefaultBytesDistribution,
|
||||
}
|
||||
|
||||
ServerSentBytesPerRPCView = &view.View{
|
||||
Name: "grpc.io/server/sent_bytes_per_rpc",
|
||||
Description: "Distribution of total sent bytes per RPC, by method.",
|
||||
Measure: ServerSentBytesPerRPC,
|
||||
TagKeys: []tag.Key{KeyServerMethod},
|
||||
Aggregation: DefaultBytesDistribution,
|
||||
}
|
||||
|
||||
ServerLatencyView = &view.View{
|
||||
Name: "grpc.io/server/server_latency",
|
||||
Description: "Distribution of server latency in milliseconds, by method.",
|
||||
TagKeys: []tag.Key{KeyServerMethod},
|
||||
Measure: ServerLatency,
|
||||
Aggregation: DefaultMillisecondsDistribution,
|
||||
}
|
||||
|
||||
ServerCompletedRPCsView = &view.View{
|
||||
Name: "grpc.io/server/completed_rpcs",
|
||||
Description: "Count of RPCs by method and status.",
|
||||
TagKeys: []tag.Key{KeyServerMethod, KeyServerStatus},
|
||||
Measure: ServerLatency,
|
||||
Aggregation: view.Count(),
|
||||
}
|
||||
|
||||
ServerReceivedMessagesPerRPCView = &view.View{
|
||||
Name: "grpc.io/server/received_messages_per_rpc",
|
||||
Description: "Distribution of messages received count per RPC, by method.",
|
||||
TagKeys: []tag.Key{KeyServerMethod},
|
||||
Measure: ServerReceivedMessagesPerRPC,
|
||||
Aggregation: DefaultMessageCountDistribution,
|
||||
}
|
||||
|
||||
ServerSentMessagesPerRPCView = &view.View{
|
||||
Name: "grpc.io/server/sent_messages_per_rpc",
|
||||
Description: "Distribution of messages sent count per RPC, by method.",
|
||||
TagKeys: []tag.Key{KeyServerMethod},
|
||||
Measure: ServerSentMessagesPerRPC,
|
||||
Aggregation: DefaultMessageCountDistribution,
|
||||
}
|
||||
)
|
||||
|
||||
// DefaultServerViews are the default server views provided by this package.
|
||||
var DefaultServerViews = []*view.View{
|
||||
ServerReceivedBytesPerRPCView,
|
||||
ServerSentBytesPerRPCView,
|
||||
ServerLatencyView,
|
||||
ServerCompletedRPCsView,
|
||||
}
|
||||
63
vendor/go.opencensus.io/plugin/ocgrpc/server_stats_handler.go
generated
vendored
Normal file
63
vendor/go.opencensus.io/plugin/ocgrpc/server_stats_handler.go
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright 2017, OpenCensus Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package ocgrpc
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"go.opencensus.io/tag"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/stats"
|
||||
)
|
||||
|
||||
// statsTagRPC gets the metadata from gRPC context, extracts the encoded tags from
|
||||
// it and creates a new tag.Map and puts them into the returned context.
|
||||
func (h *ServerHandler) statsTagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
|
||||
startTime := time.Now()
|
||||
if info == nil {
|
||||
if grpclog.V(2) {
|
||||
grpclog.Infof("opencensus: TagRPC called with nil info.")
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
d := &rpcData{
|
||||
startTime: startTime,
|
||||
method: info.FullMethodName,
|
||||
}
|
||||
propagated := h.extractPropagatedTags(ctx)
|
||||
ctx = tag.NewContext(ctx, propagated)
|
||||
ctx, _ = tag.New(ctx, tag.Upsert(KeyServerMethod, methodName(info.FullMethodName)))
|
||||
return context.WithValue(ctx, rpcDataKey, d)
|
||||
}
|
||||
|
||||
// extractPropagatedTags creates a new tag map containing the tags extracted from the
|
||||
// gRPC metadata.
|
||||
func (h *ServerHandler) extractPropagatedTags(ctx context.Context) *tag.Map {
|
||||
buf := stats.Tags(ctx)
|
||||
if buf == nil {
|
||||
return nil
|
||||
}
|
||||
propagated, err := tag.Decode(buf)
|
||||
if err != nil {
|
||||
if grpclog.V(2) {
|
||||
grpclog.Warningf("opencensus: Failed to decode tags from gRPC metadata failed to decode: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return propagated
|
||||
}
|
||||
208
vendor/go.opencensus.io/plugin/ocgrpc/stats_common.go
generated
vendored
Normal file
208
vendor/go.opencensus.io/plugin/ocgrpc/stats_common.go
generated
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
// Copyright 2017, OpenCensus Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package ocgrpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
ocstats "go.opencensus.io/stats"
|
||||
"go.opencensus.io/stats/view"
|
||||
"go.opencensus.io/tag"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/stats"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type grpcInstrumentationKey string
|
||||
|
||||
// rpcData holds the instrumentation RPC data that is needed between the start
|
||||
// and end of an call. It holds the info that this package needs to keep track
|
||||
// of between the various GRPC events.
|
||||
type rpcData struct {
|
||||
// reqCount and respCount has to be the first words
|
||||
// in order to be 64-aligned on 32-bit architectures.
|
||||
sentCount, sentBytes, recvCount, recvBytes int64 // access atomically
|
||||
|
||||
// startTime represents the time at which TagRPC was invoked at the
|
||||
// beginning of an RPC. It is an appoximation of the time when the
|
||||
// application code invoked GRPC code.
|
||||
startTime time.Time
|
||||
method string
|
||||
}
|
||||
|
||||
// The following variables define the default hard-coded auxiliary data used by
|
||||
// both the default GRPC client and GRPC server metrics.
|
||||
var (
|
||||
DefaultBytesDistribution = view.Distribution(0, 1024, 2048, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824, 4294967296)
|
||||
DefaultMillisecondsDistribution = view.Distribution(0, 0.01, 0.05, 0.1, 0.3, 0.6, 0.8, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000)
|
||||
DefaultMessageCountDistribution = view.Distribution(0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536)
|
||||
)
|
||||
|
||||
// Server tags are applied to the context used to process each RPC, as well as
|
||||
// the measures at the end of each RPC.
|
||||
var (
|
||||
KeyServerMethod, _ = tag.NewKey("grpc_server_method")
|
||||
KeyServerStatus, _ = tag.NewKey("grpc_server_status")
|
||||
)
|
||||
|
||||
// Client tags are applied to measures at the end of each RPC.
|
||||
var (
|
||||
KeyClientMethod, _ = tag.NewKey("grpc_client_method")
|
||||
KeyClientStatus, _ = tag.NewKey("grpc_client_status")
|
||||
)
|
||||
|
||||
var (
|
||||
rpcDataKey = grpcInstrumentationKey("opencensus-rpcData")
|
||||
)
|
||||
|
||||
func methodName(fullname string) string {
|
||||
return strings.TrimLeft(fullname, "/")
|
||||
}
|
||||
|
||||
// statsHandleRPC processes the RPC events.
|
||||
func statsHandleRPC(ctx context.Context, s stats.RPCStats) {
|
||||
switch st := s.(type) {
|
||||
case *stats.Begin, *stats.OutHeader, *stats.InHeader, *stats.InTrailer, *stats.OutTrailer:
|
||||
// do nothing for client
|
||||
case *stats.OutPayload:
|
||||
handleRPCOutPayload(ctx, st)
|
||||
case *stats.InPayload:
|
||||
handleRPCInPayload(ctx, st)
|
||||
case *stats.End:
|
||||
handleRPCEnd(ctx, st)
|
||||
default:
|
||||
grpclog.Infof("unexpected stats: %T", st)
|
||||
}
|
||||
}
|
||||
|
||||
func handleRPCOutPayload(ctx context.Context, s *stats.OutPayload) {
|
||||
d, ok := ctx.Value(rpcDataKey).(*rpcData)
|
||||
if !ok {
|
||||
if grpclog.V(2) {
|
||||
grpclog.Infoln("Failed to retrieve *rpcData from context.")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
atomic.AddInt64(&d.sentBytes, int64(s.Length))
|
||||
atomic.AddInt64(&d.sentCount, 1)
|
||||
}
|
||||
|
||||
func handleRPCInPayload(ctx context.Context, s *stats.InPayload) {
|
||||
d, ok := ctx.Value(rpcDataKey).(*rpcData)
|
||||
if !ok {
|
||||
if grpclog.V(2) {
|
||||
grpclog.Infoln("Failed to retrieve *rpcData from context.")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
atomic.AddInt64(&d.recvBytes, int64(s.Length))
|
||||
atomic.AddInt64(&d.recvCount, 1)
|
||||
}
|
||||
|
||||
func handleRPCEnd(ctx context.Context, s *stats.End) {
|
||||
d, ok := ctx.Value(rpcDataKey).(*rpcData)
|
||||
if !ok {
|
||||
if grpclog.V(2) {
|
||||
grpclog.Infoln("Failed to retrieve *rpcData from context.")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
elapsedTime := time.Since(d.startTime)
|
||||
|
||||
var st string
|
||||
if s.Error != nil {
|
||||
s, ok := status.FromError(s.Error)
|
||||
if ok {
|
||||
st = statusCodeToString(s)
|
||||
}
|
||||
} else {
|
||||
st = "OK"
|
||||
}
|
||||
|
||||
latencyMillis := float64(elapsedTime) / float64(time.Millisecond)
|
||||
if s.Client {
|
||||
ocstats.RecordWithTags(ctx,
|
||||
[]tag.Mutator{
|
||||
tag.Upsert(KeyClientMethod, methodName(d.method)),
|
||||
tag.Upsert(KeyClientStatus, st),
|
||||
},
|
||||
ClientSentBytesPerRPC.M(atomic.LoadInt64(&d.sentBytes)),
|
||||
ClientSentMessagesPerRPC.M(atomic.LoadInt64(&d.sentCount)),
|
||||
ClientReceivedMessagesPerRPC.M(atomic.LoadInt64(&d.recvCount)),
|
||||
ClientReceivedBytesPerRPC.M(atomic.LoadInt64(&d.recvBytes)),
|
||||
ClientRoundtripLatency.M(latencyMillis))
|
||||
} else {
|
||||
ocstats.RecordWithTags(ctx,
|
||||
[]tag.Mutator{
|
||||
tag.Upsert(KeyServerStatus, st),
|
||||
},
|
||||
ServerSentBytesPerRPC.M(atomic.LoadInt64(&d.sentBytes)),
|
||||
ServerSentMessagesPerRPC.M(atomic.LoadInt64(&d.sentCount)),
|
||||
ServerReceivedMessagesPerRPC.M(atomic.LoadInt64(&d.recvCount)),
|
||||
ServerReceivedBytesPerRPC.M(atomic.LoadInt64(&d.recvBytes)),
|
||||
ServerLatency.M(latencyMillis))
|
||||
}
|
||||
}
|
||||
|
||||
func statusCodeToString(s *status.Status) string {
|
||||
// see https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
|
||||
switch c := s.Code(); c {
|
||||
case codes.OK:
|
||||
return "OK"
|
||||
case codes.Canceled:
|
||||
return "CANCELLED"
|
||||
case codes.Unknown:
|
||||
return "UNKNOWN"
|
||||
case codes.InvalidArgument:
|
||||
return "INVALID_ARGUMENT"
|
||||
case codes.DeadlineExceeded:
|
||||
return "DEADLINE_EXCEEDED"
|
||||
case codes.NotFound:
|
||||
return "NOT_FOUND"
|
||||
case codes.AlreadyExists:
|
||||
return "ALREADY_EXISTS"
|
||||
case codes.PermissionDenied:
|
||||
return "PERMISSION_DENIED"
|
||||
case codes.ResourceExhausted:
|
||||
return "RESOURCE_EXHAUSTED"
|
||||
case codes.FailedPrecondition:
|
||||
return "FAILED_PRECONDITION"
|
||||
case codes.Aborted:
|
||||
return "ABORTED"
|
||||
case codes.OutOfRange:
|
||||
return "OUT_OF_RANGE"
|
||||
case codes.Unimplemented:
|
||||
return "UNIMPLEMENTED"
|
||||
case codes.Internal:
|
||||
return "INTERNAL"
|
||||
case codes.Unavailable:
|
||||
return "UNAVAILABLE"
|
||||
case codes.DataLoss:
|
||||
return "DATA_LOSS"
|
||||
case codes.Unauthenticated:
|
||||
return "UNAUTHENTICATED"
|
||||
default:
|
||||
return "CODE_" + strconv.FormatInt(int64(c), 10)
|
||||
}
|
||||
}
|
||||
107
vendor/go.opencensus.io/plugin/ocgrpc/trace_common.go
generated
vendored
Normal file
107
vendor/go.opencensus.io/plugin/ocgrpc/trace_common.go
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
// Copyright 2017, OpenCensus Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ocgrpc
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
|
||||
"go.opencensus.io/trace"
|
||||
"go.opencensus.io/trace/propagation"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/stats"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
const traceContextKey = "grpc-trace-bin"
|
||||
|
||||
// TagRPC creates a new trace span for the client side of the RPC.
|
||||
//
|
||||
// It returns ctx with the new trace span added and a serialization of the
|
||||
// SpanContext added to the outgoing gRPC metadata.
|
||||
func (c *ClientHandler) traceTagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context {
|
||||
name := strings.TrimPrefix(rti.FullMethodName, "/")
|
||||
name = strings.Replace(name, "/", ".", -1)
|
||||
ctx, span := trace.StartSpan(ctx, name,
|
||||
trace.WithSampler(c.StartOptions.Sampler),
|
||||
trace.WithSpanKind(trace.SpanKindClient)) // span is ended by traceHandleRPC
|
||||
traceContextBinary := propagation.Binary(span.SpanContext())
|
||||
return metadata.AppendToOutgoingContext(ctx, traceContextKey, string(traceContextBinary))
|
||||
}
|
||||
|
||||
// TagRPC creates a new trace span for the server side of the RPC.
|
||||
//
|
||||
// It checks the incoming gRPC metadata in ctx for a SpanContext, and if
|
||||
// it finds one, uses that SpanContext as the parent context of the new span.
|
||||
//
|
||||
// It returns ctx, with the new trace span added.
|
||||
func (s *ServerHandler) traceTagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context {
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
name := strings.TrimPrefix(rti.FullMethodName, "/")
|
||||
name = strings.Replace(name, "/", ".", -1)
|
||||
traceContext := md[traceContextKey]
|
||||
var (
|
||||
parent trace.SpanContext
|
||||
haveParent bool
|
||||
)
|
||||
if len(traceContext) > 0 {
|
||||
// Metadata with keys ending in -bin are actually binary. They are base64
|
||||
// encoded before being put on the wire, see:
|
||||
// https://github.com/grpc/grpc-go/blob/08d6261/Documentation/grpc-metadata.md#storing-binary-data-in-metadata
|
||||
traceContextBinary := []byte(traceContext[0])
|
||||
parent, haveParent = propagation.FromBinary(traceContextBinary)
|
||||
if haveParent && !s.IsPublicEndpoint {
|
||||
ctx, _ := trace.StartSpanWithRemoteParent(ctx, name, parent,
|
||||
trace.WithSpanKind(trace.SpanKindServer),
|
||||
trace.WithSampler(s.StartOptions.Sampler),
|
||||
)
|
||||
return ctx
|
||||
}
|
||||
}
|
||||
ctx, span := trace.StartSpan(ctx, name,
|
||||
trace.WithSpanKind(trace.SpanKindServer),
|
||||
trace.WithSampler(s.StartOptions.Sampler))
|
||||
if haveParent {
|
||||
span.AddLink(trace.Link{TraceID: parent.TraceID, SpanID: parent.SpanID, Type: trace.LinkTypeChild})
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
func traceHandleRPC(ctx context.Context, rs stats.RPCStats) {
|
||||
span := trace.FromContext(ctx)
|
||||
// TODO: compressed and uncompressed sizes are not populated in every message.
|
||||
switch rs := rs.(type) {
|
||||
case *stats.Begin:
|
||||
span.AddAttributes(
|
||||
trace.BoolAttribute("Client", rs.Client),
|
||||
trace.BoolAttribute("FailFast", rs.FailFast))
|
||||
case *stats.InPayload:
|
||||
span.AddMessageReceiveEvent(0 /* TODO: messageID */, int64(rs.Length), int64(rs.WireLength))
|
||||
case *stats.OutPayload:
|
||||
span.AddMessageSendEvent(0, int64(rs.Length), int64(rs.WireLength))
|
||||
case *stats.End:
|
||||
if rs.Error != nil {
|
||||
s, ok := status.FromError(rs.Error)
|
||||
if ok {
|
||||
span.SetStatus(trace.Status{Code: int32(s.Code()), Message: s.Message()})
|
||||
} else {
|
||||
span.SetStatus(trace.Status{Code: int32(codes.Internal), Message: rs.Error.Error()})
|
||||
}
|
||||
}
|
||||
span.End()
|
||||
}
|
||||
}
|
||||
5
vendor/modules.txt
vendored
5
vendor/modules.txt
vendored
@@ -128,6 +128,7 @@ github.com/sirupsen/logrus/hooks/syslog
|
||||
# github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f
|
||||
github.com/ugorji/go/codec
|
||||
# go.opencensus.io v0.19.0
|
||||
go.opencensus.io/plugin/ocgrpc
|
||||
go.opencensus.io/plugin/ochttp
|
||||
go.opencensus.io/stats
|
||||
go.opencensus.io/stats/view
|
||||
@@ -181,12 +182,13 @@ google.golang.org/grpc/credentials
|
||||
google.golang.org/grpc/metadata
|
||||
google.golang.org/grpc/peer
|
||||
google.golang.org/grpc/status
|
||||
google.golang.org/grpc/grpclog
|
||||
google.golang.org/grpc/stats
|
||||
google.golang.org/grpc/balancer
|
||||
google.golang.org/grpc/balancer/roundrobin
|
||||
google.golang.org/grpc/connectivity
|
||||
google.golang.org/grpc/encoding
|
||||
google.golang.org/grpc/encoding/proto
|
||||
google.golang.org/grpc/grpclog
|
||||
google.golang.org/grpc/internal
|
||||
google.golang.org/grpc/internal/backoff
|
||||
google.golang.org/grpc/internal/binarylog
|
||||
@@ -200,7 +202,6 @@ google.golang.org/grpc/naming
|
||||
google.golang.org/grpc/resolver
|
||||
google.golang.org/grpc/resolver/dns
|
||||
google.golang.org/grpc/resolver/passthrough
|
||||
google.golang.org/grpc/stats
|
||||
google.golang.org/grpc/tap
|
||||
google.golang.org/grpc/credentials/internal
|
||||
google.golang.org/grpc/balancer/base
|
||||
|
||||
Reference in New Issue
Block a user