Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Kochie <bjk@gitlab.com>2018-11-13 06:38:50 +0300
committerBen Kochie <bjk@gitlab.com>2018-11-13 06:38:50 +0300
commit9cd8456f5a451319278d19b43278a8efdc5db489 (patch)
treeeb0d41db873e19a6956c8a8f600e9ae8d5561cbf
parent6d81554fb674ac78bf835470adcca19240e1c5e4 (diff)
Rollback vendor go-grpc-middlewarebjk/565_rollback
Rollback venoring of github.com/grpc-ecosystem/go-grpc-middleware/... to commit `82921fcf811d228d2fa202bc31238b356bf9f8d5`.
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/CONTRIBUTING.md20
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/DOC.md12
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/Gopkg.lock123
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/Gopkg.toml35
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/README.md2
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/auth/DOC.md68
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/auth/README.md68
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go16
-rwxr-xr-xvendor/github.com/grpc-ecosystem/go-grpc-middleware/checkup.sh21
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/doc.go2
-rwxr-xr-xvendor/github.com/grpc-ecosystem/go-grpc-middleware/fixup.sh36
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/DOC.md29
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/README.md29
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/common.go9
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/doc.go10
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/DOC.md257
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/README.md257
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/context.go31
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/DOC.md93
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/README.md58
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/context.go65
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/doc.go14
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/doc.go57
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/noop.go (renamed from vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/noop.go)2
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/options.go13
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/payload_interceptors.go15
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/server_interceptors.go62
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/makefile22
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/slack.pngbin5088 -> 0 bytes
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/DOC.md113
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/README.md113
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/context.go59
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/doc.go3
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/fieldextractor.go4
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/interceptors.go6
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/logrus/context.go25
-rwxr-xr-xvendor/github.com/grpc-ecosystem/go-grpc-middleware/test_all.sh14
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/util/metautils/DOC.md4
-rw-r--r--vendor/github.com/grpc-ecosystem/go-grpc-middleware/util/metautils/README.md4
-rw-r--r--vendor/vendor.json56
40 files changed, 510 insertions, 1317 deletions
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/CONTRIBUTING.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/CONTRIBUTING.md
deleted file mode 100644
index dd52ab893..000000000
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/CONTRIBUTING.md
+++ /dev/null
@@ -1,20 +0,0 @@
-# Contributing
-
-We would love to have people submit pull requests and help make `grpc-ecosystem/go-grpc-middleware` even better 👍.
-
-Fork, then clone the repo:
-
-```bash
-git clone git@github.com:your-username/go-grpc-middleware.git
-```
-
-Before checking in please run the following:
-
-```bash
-make all
-```
-
-This will `vet`, `fmt`, regenerate documentation and run all tests.
-
-
-Push to your fork and open a pull request. \ No newline at end of file
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/DOC.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/DOC.md
index 511d953a8..a06d61fdb 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/DOC.md
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/DOC.md
@@ -42,8 +42,6 @@ Here's an example for client side chaining:
These interceptors will be executed from left to right: monitoring and then retry logic.
-The retry interceptor will call every interceptor that follows it whenever when a retry happens.
-
### Writing Your Own
Implementing your own interceptor is pretty trivial: there are interfaces for that. But the interesting
bit exposing common data to handlers (and other middleware), similarly to HTTP Middleware design.
@@ -86,7 +84,7 @@ needed. For example:
#### <a name="pkg-files">Package files</a>
[chain.go](./chain.go) [doc.go](./doc.go) [wrappers.go](./wrappers.go)
-## <a name="ChainStreamClient">func</a> [ChainStreamClient](./chain.go#L136)
+## <a name="ChainStreamClient">func</a> [ChainStreamClient](./chain.go#L106)
``` go
func ChainStreamClient(interceptors ...grpc.StreamClientInterceptor) grpc.StreamClientInterceptor
```
@@ -95,7 +93,7 @@ ChainStreamClient creates a single interceptor out of a chain of many intercepto
Execution is done in left-to-right order, including passing of context.
For example ChainStreamClient(one, two, three) will execute one before two before three.
-## <a name="ChainStreamServer">func</a> [ChainStreamServer](./chain.go#L58)
+## <a name="ChainStreamServer">func</a> [ChainStreamServer](./chain.go#L48)
``` go
func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor
```
@@ -105,7 +103,7 @@ Execution is done in left-to-right order, including passing of context.
For example ChainUnaryServer(one, two, three) will execute one before two before three.
If you want to pass context between interceptors, use WrapServerStream.
-## <a name="ChainUnaryClient">func</a> [ChainUnaryClient](./chain.go#L97)
+## <a name="ChainUnaryClient">func</a> [ChainUnaryClient](./chain.go#L77)
``` go
func ChainUnaryClient(interceptors ...grpc.UnaryClientInterceptor) grpc.UnaryClientInterceptor
```
@@ -124,14 +122,14 @@ Execution is done in left-to-right order, including passing of context.
For example ChainUnaryServer(one, two, three) will execute one before two before three, and three
will see context changes of one and two.
-## <a name="WithStreamServerChain">func</a> [WithStreamServerChain](./chain.go#L181)
+## <a name="WithStreamServerChain">func</a> [WithStreamServerChain](./chain.go#L141)
``` go
func WithStreamServerChain(interceptors ...grpc.StreamServerInterceptor) grpc.ServerOption
```
WithStreamServerChain is a grpc.Server config option that accepts multiple stream interceptors.
Basically syntactic sugar.
-## <a name="WithUnaryServerChain">func</a> [WithUnaryServerChain](./chain.go#L175)
+## <a name="WithUnaryServerChain">func</a> [WithUnaryServerChain](./chain.go#L135)
``` go
func WithUnaryServerChain(interceptors ...grpc.UnaryServerInterceptor) grpc.ServerOption
```
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/Gopkg.lock b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/Gopkg.lock
deleted file mode 100644
index ebdcb75a8..000000000
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/Gopkg.lock
+++ /dev/null
@@ -1,123 +0,0 @@
-# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
-
-
-[[projects]]
- name = "cloud.google.com/go"
- packages = ["compute/metadata"]
- revision = "2d3a6656c17a60b0815b7e06ab0be04eacb6e613"
- version = "v0.16.0"
-
-[[projects]]
- name = "github.com/davecgh/go-spew"
- packages = ["spew"]
- revision = "346938d642f2ec3594ed81d874461961cd0faa76"
- version = "v1.1.0"
-
-[[projects]]
- name = "github.com/gogo/protobuf"
- packages = ["gogoproto","proto","protoc-gen-gogo/descriptor"]
- revision = "342cbe0a04158f6dcb03ca0079991a51a4248c02"
- version = "v0.5"
-
-[[projects]]
- branch = "master"
- name = "github.com/golang/protobuf"
- packages = ["jsonpb","proto","ptypes","ptypes/any","ptypes/duration","ptypes/struct","ptypes/timestamp"]
- revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845"
-
-[[projects]]
- name = "github.com/opentracing/opentracing-go"
- packages = [".","ext","log","mocktracer"]
- revision = "1949ddbfd147afd4d964a9f00b24eb291e0e7c38"
- version = "v1.0.2"
-
-[[projects]]
- name = "github.com/pmezard/go-difflib"
- packages = ["difflib"]
- revision = "792786c7400a136282c1664665ae0a8db921c6c2"
- version = "v1.0.0"
-
-[[projects]]
- name = "github.com/sirupsen/logrus"
- packages = ["."]
- revision = "f006c2ac4710855cf0f916dd6b77acf6b048dc6e"
- version = "v1.0.3"
-
-[[projects]]
- name = "github.com/stretchr/testify"
- packages = ["assert","require","suite"]
- revision = "69483b4bd14f5845b5a1e55bca19e954e827f1d0"
- version = "v1.1.4"
-
-[[projects]]
- name = "go.uber.org/atomic"
- packages = ["."]
- revision = "8474b86a5a6f79c443ce4b2992817ff32cf208b8"
- version = "v1.3.1"
-
-[[projects]]
- name = "go.uber.org/multierr"
- packages = ["."]
- revision = "3c4937480c32f4c13a875a1829af76c98ca3d40a"
- version = "v1.1.0"
-
-[[projects]]
- name = "go.uber.org/zap"
- packages = [".","buffer","internal/bufferpool","internal/color","internal/exit","zapcore"]
- revision = "35aad584952c3e7020db7b839f6b102de6271f89"
- version = "v1.7.1"
-
-[[projects]]
- branch = "master"
- name = "golang.org/x/crypto"
- packages = ["ssh/terminal"]
- revision = "94eea52f7b742c7cbe0b03b22f0c4c8631ece122"
-
-[[projects]]
- branch = "master"
- name = "golang.org/x/net"
- packages = ["context","context/ctxhttp","http2","http2/hpack","idna","internal/timeseries","lex/httplex","trace"]
- revision = "a8b9294777976932365dabb6640cf1468d95c70f"
-
-[[projects]]
- branch = "master"
- name = "golang.org/x/oauth2"
- packages = [".","google","internal","jws","jwt"]
- revision = "f95fa95eaa936d9d87489b15d1d18b97c1ba9c28"
-
-[[projects]]
- branch = "master"
- name = "golang.org/x/sys"
- packages = ["unix","windows"]
- revision = "13fcbd661c8ececa8807a29b48407d674b1d8ed8"
-
-[[projects]]
- branch = "master"
- 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","unicode/cldr","unicode/norm","unicode/rangetable"]
- revision = "75cc3cad82b5f47d3fb229ddda8c5167da14f294"
-
-[[projects]]
- name = "google.golang.org/appengine"
- packages = [".","internal","internal/app_identity","internal/base","internal/datastore","internal/log","internal/modules","internal/remote_api","internal/urlfetch","urlfetch"]
- revision = "150dc57a1b433e64154302bdc40b6bb8aefa313a"
- version = "v1.0.0"
-
-[[projects]]
- branch = "master"
- name = "google.golang.org/genproto"
- packages = ["googleapis/rpc/status"]
- revision = "7f0da29060c682909f650ad8ed4e515bd74fa12a"
-
-[[projects]]
- name = "google.golang.org/grpc"
- packages = [".","balancer","balancer/roundrobin","codes","connectivity","credentials","credentials/oauth","encoding","grpclb/grpc_lb_v1/messages","grpclog","internal","keepalive","metadata","naming","peer","resolver","resolver/dns","resolver/passthrough","stats","status","tap","transport"]
- revision = "5a9f7b402fe85096d2e1d0383435ee1876e863d0"
- version = "v1.8.0"
-
-[solve-meta]
- analyzer-name = "dep"
- analyzer-version = 1
- inputs-digest = "b24c6670412eb0bc44ed1db77fecc52333f8725f3e3272bdc568f5683a63031f"
- solver-name = "gps-cdcl"
- solver-version = 1
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/Gopkg.toml b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/Gopkg.toml
deleted file mode 100644
index 0a7d4c1cd..000000000
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/Gopkg.toml
+++ /dev/null
@@ -1,35 +0,0 @@
-[[constraint]]
- name = "github.com/gogo/protobuf"
- version = "0.5.0"
-
-[[constraint]]
- branch = "master"
- name = "github.com/golang/protobuf"
-
-[[constraint]]
- name = "github.com/opentracing/opentracing-go"
- version = "1.0.2"
-
-[[constraint]]
- name = "github.com/sirupsen/logrus"
- version = "1.0.3"
-
-[[constraint]]
- name = "github.com/stretchr/testify"
- version = "1.1.4"
-
-[[constraint]]
- name = "go.uber.org/zap"
- version = "1.7.1"
-
-[[constraint]]
- branch = "master"
- name = "golang.org/x/net"
-
-[[constraint]]
- branch = "master"
- name = "golang.org/x/oauth2"
-
-[[constraint]]
- name = "google.golang.org/grpc"
- version = "1.8.0"
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/README.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/README.md
index 52e53733c..4fe246f24 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/README.md
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/README.md
@@ -7,7 +7,7 @@
[![codecov](https://codecov.io/gh/grpc-ecosystem/go-grpc-middleware/branch/master/graph/badge.svg)](https://codecov.io/gh/grpc-ecosystem/go-grpc-middleware)
[![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![quality: production](https://img.shields.io/badge/quality-production-orange.svg)](#status)
-[![Slack](slack.png)](https://join.slack.com/t/improbable-eng/shared_invite/enQtMzQ1ODcyMzQ5MjM4LWY5ZWZmNGM2ODc5MmViNmQ3ZTA3ZTY3NzQwOTBlMTkzZmIxZTIxODk0OWU3YjZhNWVlNDU3MDlkZGViZjhkMjc)
+
[gRPC Go](https://github.com/grpc/grpc-go) Middleware: interceptors, helpers, utilities.
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/auth/DOC.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/auth/DOC.md
index 5834112b0..5c4de1179 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/auth/DOC.md
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/auth/DOC.md
@@ -27,49 +27,32 @@ Please see examples for simple examples of use.
<summary>Click to expand code.</summary>
```go
-package grpc_auth_test
-
-import (
- "github.com/grpc-ecosystem/go-grpc-middleware/auth"
- "github.com/grpc-ecosystem/go-grpc-middleware/tags"
- "golang.org/x/net/context"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
-)
-
-var (
- cc *grpc.ClientConn
-)
-
-func parseToken(token string) (struct{}, error) {
- return struct{}{}, nil
-}
+token, err := grpc_auth.AuthFromMD(ctx, "bearer")
+ if err != nil {
+ return nil, err
+ }
+ tokenInfo, err := parseToken(token)
+ if err != nil {
+ return nil, grpc.Errorf(codes.Unauthenticated, "invalid auth token: %v", err)
+ }
+ grpc_ctxtags.Extract(ctx).Set("auth.sub", userClaimFromToken(tokenInfo))
+ newCtx := context.WithValue(ctx, "tokenInfo", tokenInfo)
+ return newCtx, nil
+```
-func userClaimFromToken(struct{}) string {
- return "foobar"
-}
+</details>
-// Simple example of server initialization code.
-func Example_serverConfig() {
- exampleAuthFunc := func(ctx context.Context) (context.Context, error) {
- token, err := grpc_auth.AuthFromMD(ctx, "bearer")
- if err != nil {
- return nil, err
- }
- tokenInfo, err := parseToken(token)
- if err != nil {
- return nil, grpc.Errorf(codes.Unauthenticated, "invalid auth token: %v", err)
- }
- grpc_ctxtags.Extract(ctx).Set("auth.sub", userClaimFromToken(tokenInfo))
- newCtx := context.WithValue(ctx, "tokenInfo", tokenInfo)
- return newCtx, nil
- }
-
- _ = grpc.NewServer(
- grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(exampleAuthFunc)),
- grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(exampleAuthFunc)),
- )
-}
+#### Example:
+
+<details>
+<summary>Click to expand code.</summary>
+
+```go
+server := grpc.NewServer(
+ grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(Example_authfunc)),
+ grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(Example_authfunc)),
+ )
+ return server
```
</details>
@@ -90,7 +73,8 @@ func Example_serverConfig() {
* [type ServiceAuthFuncOverride](#ServiceAuthFuncOverride)
#### <a name="pkg-examples">Examples</a>
-* [Package (ServerConfig)](#example__serverConfig)
+* [Package (Authfunc)](#example__authfunc)
+* [Package (Serverconfig)](#example__serverconfig)
#### <a name="pkg-files">Package files</a>
[auth.go](./auth.go) [doc.go](./doc.go) [metadata.go](./metadata.go)
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/auth/README.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/auth/README.md
index 5834112b0..5c4de1179 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/auth/README.md
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/auth/README.md
@@ -27,49 +27,32 @@ Please see examples for simple examples of use.
<summary>Click to expand code.</summary>
```go
-package grpc_auth_test
-
-import (
- "github.com/grpc-ecosystem/go-grpc-middleware/auth"
- "github.com/grpc-ecosystem/go-grpc-middleware/tags"
- "golang.org/x/net/context"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
-)
-
-var (
- cc *grpc.ClientConn
-)
-
-func parseToken(token string) (struct{}, error) {
- return struct{}{}, nil
-}
+token, err := grpc_auth.AuthFromMD(ctx, "bearer")
+ if err != nil {
+ return nil, err
+ }
+ tokenInfo, err := parseToken(token)
+ if err != nil {
+ return nil, grpc.Errorf(codes.Unauthenticated, "invalid auth token: %v", err)
+ }
+ grpc_ctxtags.Extract(ctx).Set("auth.sub", userClaimFromToken(tokenInfo))
+ newCtx := context.WithValue(ctx, "tokenInfo", tokenInfo)
+ return newCtx, nil
+```
-func userClaimFromToken(struct{}) string {
- return "foobar"
-}
+</details>
-// Simple example of server initialization code.
-func Example_serverConfig() {
- exampleAuthFunc := func(ctx context.Context) (context.Context, error) {
- token, err := grpc_auth.AuthFromMD(ctx, "bearer")
- if err != nil {
- return nil, err
- }
- tokenInfo, err := parseToken(token)
- if err != nil {
- return nil, grpc.Errorf(codes.Unauthenticated, "invalid auth token: %v", err)
- }
- grpc_ctxtags.Extract(ctx).Set("auth.sub", userClaimFromToken(tokenInfo))
- newCtx := context.WithValue(ctx, "tokenInfo", tokenInfo)
- return newCtx, nil
- }
-
- _ = grpc.NewServer(
- grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(exampleAuthFunc)),
- grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(exampleAuthFunc)),
- )
-}
+#### Example:
+
+<details>
+<summary>Click to expand code.</summary>
+
+```go
+server := grpc.NewServer(
+ grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(Example_authfunc)),
+ grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(Example_authfunc)),
+ )
+ return server
```
</details>
@@ -90,7 +73,8 @@ func Example_serverConfig() {
* [type ServiceAuthFuncOverride](#ServiceAuthFuncOverride)
#### <a name="pkg-examples">Examples</a>
-* [Package (ServerConfig)](#example__serverConfig)
+* [Package (Authfunc)](#example__authfunc)
+* [Package (Serverconfig)](#example__serverconfig)
#### <a name="pkg-files">Package files</a>
[auth.go](./auth.go) [doc.go](./doc.go) [metadata.go](./metadata.go)
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go
index 45a2f5f49..7e82a081c 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go
@@ -31,9 +31,7 @@ func ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnarySer
return handler(currentCtx, currentReq)
}
curI++
- resp, err := interceptors[curI](currentCtx, currentReq, info, chainHandler)
- curI--
- return resp, err
+ return interceptors[curI](currentCtx, currentReq, info, chainHandler)
}
return interceptors[0](ctx, req, info, chainHandler)
@@ -71,9 +69,7 @@ func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.Stream
return handler(currentSrv, currentStream)
}
curI++
- err := interceptors[curI](currentSrv, currentStream, info, chainHandler)
- curI--
- return err
+ return interceptors[curI](currentSrv, currentStream, info, chainHandler)
}
return interceptors[0](srv, stream, info, chainHandler)
@@ -110,9 +106,7 @@ func ChainUnaryClient(interceptors ...grpc.UnaryClientInterceptor) grpc.UnaryCli
return invoker(currentCtx, currentMethod, currentReq, currentRepl, currentConn, currentOpts...)
}
curI++
- err := interceptors[curI](currentCtx, currentMethod, currentReq, currentRepl, currentConn, chainHandler, currentOpts...)
- curI--
- return err
+ return interceptors[curI](currentCtx, currentMethod, currentReq, currentRepl, currentConn, chainHandler, currentOpts...)
}
return interceptors[0](ctx, method, req, reply, cc, chainHandler, opts...)
@@ -149,9 +143,7 @@ func ChainStreamClient(interceptors ...grpc.StreamClientInterceptor) grpc.Stream
return streamer(currentCtx, currentDesc, currentConn, currentMethod, currentOpts...)
}
curI++
- stream, err := interceptors[curI](currentCtx, currentDesc, currentConn, currentMethod, chainHandler, currentOpts...)
- curI--
- return stream, err
+ return interceptors[curI](currentCtx, currentDesc, currentConn, currentMethod, chainHandler, currentOpts...)
}
return interceptors[0](ctx, desc, cc, method, chainHandler, opts...)
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/checkup.sh b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/checkup.sh
new file mode 100755
index 000000000..37e9aac6e
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/checkup.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+# Script that checks up code (govet).
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
+
+function print_real_go_files {
+ grep --files-without-match 'DO NOT EDIT!' $(find . -iname '*.go')
+}
+
+function govet_all {
+ ret=0
+ for i in $(print_real_go_files); do
+ output=$(go tool vet -all=true -tests=false ${i})
+ ret=$(($ret | $?))
+ echo -n ${output}
+ done;
+ return ${ret}
+}
+
+govet_all
+echo "returning $?" \ No newline at end of file
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/doc.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/doc.go
index 716895036..bd6b41477 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/doc.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/doc.go
@@ -40,8 +40,6 @@ Here's an example for client side chaining:
These interceptors will be executed from left to right: monitoring and then retry logic.
-The retry interceptor will call every interceptor that follows it whenever when a retry happens.
-
Writing Your Own
Implementing your own interceptor is pretty trivial: there are interfaces for that. But the interesting
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/fixup.sh b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/fixup.sh
new file mode 100755
index 000000000..850ec557d
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/fixup.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# Script that checks the code for errors.
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
+GOBIN=${GOBIN:="$GOPATH/bin"}
+
+function print_real_go_files {
+ grep --files-without-match 'DO NOT EDIT!' $(find . -iname '*.go')
+}
+
+function generate_markdown {
+ echo "Generating Github markdown"
+ oldpwd=$(pwd)
+ for i in $(find . -iname 'doc.go'); do
+ dir=${i%/*}
+ realdir=$(realpath $dir)
+ package=${realdir##${GOPATH}/src/}
+ echo "$package"
+ cd ${dir}
+ ${GOBIN}/godoc2ghmd -ex -file DOC.md ${package}
+ ln -s DOC.md README.md 2> /dev/null # can fail
+ cd ${oldpwd}
+ done;
+}
+
+function goimports_all {
+ echo "Running goimports"
+ goimports -l -w $(print_real_go_files)
+ return $?
+}
+
+go get github.com/davecheney/godoc2md
+
+generate_markdown
+goimports_all
+echo "returning $?"
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/DOC.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/DOC.md
index 9deb4722c..3f86b5007 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/DOC.md
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/DOC.md
@@ -6,14 +6,12 @@
* [Index](#pkg-index)
## <a name="pkg-overview">Overview</a>
-grpc_logging is a "parent" package for gRPC logging middlewares.
+grpc_logging is a "parent" package for gRPC logging middlewares
### General functionality of all middleware
-The gRPC logging middleware populates request-scoped data to `grpc_ctxtags.Tags` that relate to the current gRPC call
-(e.g. service and method names).
-
-Once the gRPC logging middleware has added the gRPC specific Tags to the ctx they will then be written with the logs
-that are made using the `ctx_logrus` or `ctx_zap` loggers.
+All logging middleware have an `Extract(ctx)` function that provides a request-scoped logger with gRPC-related fields
+(service and method names). Moreover, that logger will have fields populated from the `grpc_ctxtags.Tags` of the
+context.
All logging middleware will emit a final log statement. It is based on the error returned by the handler function,
the gRPC status code, an error (if any) and it will emit at a level controlled via `WithLevels`.
@@ -38,41 +36,26 @@ See relevant packages below.
- [google.golang.org/grpc/codes](https://godoc.org/google.golang.org/grpc/codes)
## <a name="pkg-index">Index</a>
-* [func DefaultDeciderMethod(fullMethodName string, err error) bool](#DefaultDeciderMethod)
* [func DefaultErrorToCode(err error) codes.Code](#DefaultErrorToCode)
* [type ClientPayloadLoggingDecider](#ClientPayloadLoggingDecider)
-* [type Decider](#Decider)
* [type ErrorToCode](#ErrorToCode)
* [type ServerPayloadLoggingDecider](#ServerPayloadLoggingDecider)
#### <a name="pkg-files">Package files</a>
[common.go](./common.go) [doc.go](./doc.go)
-## <a name="DefaultDeciderMethod">func</a> [DefaultDeciderMethod](./common.go#L25)
-``` go
-func DefaultDeciderMethod(fullMethodName string, err error) bool
-```
-DefaultDeciderMethod is the default implementation of decider to see if you should log the call
-by default this if always true so all calls are logged
-
## <a name="DefaultErrorToCode">func</a> [DefaultErrorToCode](./common.go#L16)
``` go
func DefaultErrorToCode(err error) codes.Code
```
-## <a name="ClientPayloadLoggingDecider">type</a> [ClientPayloadLoggingDecider](./common.go#L35)
+## <a name="ClientPayloadLoggingDecider">type</a> [ClientPayloadLoggingDecider](./common.go#L26)
``` go
type ClientPayloadLoggingDecider func(ctx context.Context, fullMethodName string) bool
```
ClientPayloadLoggingDecider is a user-provided function for deciding whether to log the client-side
request/response payloads
-## <a name="Decider">type</a> [Decider](./common.go#L21)
-``` go
-type Decider func(fullMethodName string, err error) bool
-```
-Decider function defines rules for suppressing any interceptor logs
-
## <a name="ErrorToCode">type</a> [ErrorToCode](./common.go#L14)
``` go
type ErrorToCode func(err error) codes.Code
@@ -80,7 +63,7 @@ type ErrorToCode func(err error) codes.Code
ErrorToCode function determines the error code of an error
This makes using custom errors with grpc middleware easier
-## <a name="ServerPayloadLoggingDecider">type</a> [ServerPayloadLoggingDecider](./common.go#L31)
+## <a name="ServerPayloadLoggingDecider">type</a> [ServerPayloadLoggingDecider](./common.go#L22)
``` go
type ServerPayloadLoggingDecider func(ctx context.Context, fullMethodName string, servingObject interface{}) bool
```
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/README.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/README.md
index 9deb4722c..3f86b5007 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/README.md
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/README.md
@@ -6,14 +6,12 @@
* [Index](#pkg-index)
## <a name="pkg-overview">Overview</a>
-grpc_logging is a "parent" package for gRPC logging middlewares.
+grpc_logging is a "parent" package for gRPC logging middlewares
### General functionality of all middleware
-The gRPC logging middleware populates request-scoped data to `grpc_ctxtags.Tags` that relate to the current gRPC call
-(e.g. service and method names).
-
-Once the gRPC logging middleware has added the gRPC specific Tags to the ctx they will then be written with the logs
-that are made using the `ctx_logrus` or `ctx_zap` loggers.
+All logging middleware have an `Extract(ctx)` function that provides a request-scoped logger with gRPC-related fields
+(service and method names). Moreover, that logger will have fields populated from the `grpc_ctxtags.Tags` of the
+context.
All logging middleware will emit a final log statement. It is based on the error returned by the handler function,
the gRPC status code, an error (if any) and it will emit at a level controlled via `WithLevels`.
@@ -38,41 +36,26 @@ See relevant packages below.
- [google.golang.org/grpc/codes](https://godoc.org/google.golang.org/grpc/codes)
## <a name="pkg-index">Index</a>
-* [func DefaultDeciderMethod(fullMethodName string, err error) bool](#DefaultDeciderMethod)
* [func DefaultErrorToCode(err error) codes.Code](#DefaultErrorToCode)
* [type ClientPayloadLoggingDecider](#ClientPayloadLoggingDecider)
-* [type Decider](#Decider)
* [type ErrorToCode](#ErrorToCode)
* [type ServerPayloadLoggingDecider](#ServerPayloadLoggingDecider)
#### <a name="pkg-files">Package files</a>
[common.go](./common.go) [doc.go](./doc.go)
-## <a name="DefaultDeciderMethod">func</a> [DefaultDeciderMethod](./common.go#L25)
-``` go
-func DefaultDeciderMethod(fullMethodName string, err error) bool
-```
-DefaultDeciderMethod is the default implementation of decider to see if you should log the call
-by default this if always true so all calls are logged
-
## <a name="DefaultErrorToCode">func</a> [DefaultErrorToCode](./common.go#L16)
``` go
func DefaultErrorToCode(err error) codes.Code
```
-## <a name="ClientPayloadLoggingDecider">type</a> [ClientPayloadLoggingDecider](./common.go#L35)
+## <a name="ClientPayloadLoggingDecider">type</a> [ClientPayloadLoggingDecider](./common.go#L26)
``` go
type ClientPayloadLoggingDecider func(ctx context.Context, fullMethodName string) bool
```
ClientPayloadLoggingDecider is a user-provided function for deciding whether to log the client-side
request/response payloads
-## <a name="Decider">type</a> [Decider](./common.go#L21)
-``` go
-type Decider func(fullMethodName string, err error) bool
-```
-Decider function defines rules for suppressing any interceptor logs
-
## <a name="ErrorToCode">type</a> [ErrorToCode](./common.go#L14)
``` go
type ErrorToCode func(err error) codes.Code
@@ -80,7 +63,7 @@ type ErrorToCode func(err error) codes.Code
ErrorToCode function determines the error code of an error
This makes using custom errors with grpc middleware easier
-## <a name="ServerPayloadLoggingDecider">type</a> [ServerPayloadLoggingDecider](./common.go#L31)
+## <a name="ServerPayloadLoggingDecider">type</a> [ServerPayloadLoggingDecider](./common.go#L22)
``` go
type ServerPayloadLoggingDecider func(ctx context.Context, fullMethodName string, servingObject interface{}) bool
```
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/common.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/common.go
index f725d038a..a367b72a1 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/common.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/common.go
@@ -17,15 +17,6 @@ func DefaultErrorToCode(err error) codes.Code {
return grpc.Code(err)
}
-// Decider function defines rules for suppressing any interceptor logs
-type Decider func(fullMethodName string, err error) bool
-
-// DefaultDeciderMethod is the default implementation of decider to see if you should log the call
-// by default this if always true so all calls are logged
-func DefaultDeciderMethod(fullMethodName string, err error) bool {
- return true
-}
-
// ServerPayloadLoggingDecider is a user-provided function for deciding whether to log the server-side
// request/response payloads
type ServerPayloadLoggingDecider func(ctx context.Context, fullMethodName string, servingObject interface{}) bool
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/doc.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/doc.go
index ce8bb2987..02295dfcc 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/doc.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/doc.go
@@ -3,15 +3,13 @@
//
/*
-grpc_logging is a "parent" package for gRPC logging middlewares.
+grpc_logging is a "parent" package for gRPC logging middlewares
General functionality of all middleware
-The gRPC logging middleware populates request-scoped data to `grpc_ctxtags.Tags` that relate to the current gRPC call
-(e.g. service and method names).
-
-Once the gRPC logging middleware has added the gRPC specific Tags to the ctx they will then be written with the logs
-that are made using the `ctx_logrus` or `ctx_zap` loggers.
+All logging middleware have an `Extract(ctx)` function that provides a request-scoped logger with gRPC-related fields
+(service and method names). Moreover, that logger will have fields populated from the `grpc_ctxtags.Tags` of the
+context.
All logging middleware will emit a final log statement. It is based on the error returned by the handler function,
the gRPC status code, an error (if any) and it will emit at a level controlled via `WithLevels`.
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/DOC.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/DOC.md
index 7a1bb9394..ba136f195 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/DOC.md
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/DOC.md
@@ -12,65 +12,35 @@
It accepts a user-configured `logrus.Entry` that will be used for logging completed gRPC calls. The same
`logrus.Entry` will be used for logging completed gRPC calls, and be populated into the `context.Context` passed into gRPC handler code.
-On calling `StreamServerInterceptor` or `UnaryServerInterceptor` this logging middleware will add gRPC call information
-to the ctx so that it will be present on subsequent use of the `ctxlogrus` logger.
+You can use `Extract` to log into a request-scoped `logrus.Entry` instance in your handler code. The fields set on the
+logger correspond to the grpc_ctxtags.Tags attached to the context.
This package also implements request and response *payload* logging, both for server-side and client-side. These will be
-logged as structured `jsonpb` fields for every message received/sent (both unary and streaming). For that please use
+logged as structured `jsonbp` fields for every message received/sent (both unary and streaming). For that please use
`Payload*Interceptor` functions for that. Please note that the user-provided function that determines whetether to log
the full request/response payload needs to be written with care, this can significantly slow down gRPC.
-If a deadline is present on the gRPC request the grpc.request.deadline tag is populated when the request begins. grpc.request.deadline
-is a string representing the time (RFC3339) when the current call will expire.
-
Logrus can also be made as a backend for gRPC library internals. For that use `ReplaceGrpcLogger`.
-*Server Interceptor*
-Below is a JSON formatted example of a log that would be logged by the server interceptor:
-
- {
- "level": "info", // string logrus log levels
- "msg": "finished unary call", // string log message
- "grpc.code": "OK", // string grpc status code
- "grpc.method": "Ping", // string method name
- "grpc.service": "mwitkow.testproto.TestService", // string full name of the called service
- "grpc.start_time": "2006-01-02T15:04:05Z07:00", // string RFC3339 representation of the start time
- "grpc.request.deadline": "2006-01-02T15:04:05Z07:00", // string RFC3339 deadline of the current request if supplied
- "grpc.request.value": "something", // string value on the request
- "grpc.time_ms": 1.234, // float32 run time of the call in ms
- "peer.address": {
- "IP": "127.0.0.1", // string IP address of calling party
- "Port": 60216, // int port call is coming in on
- "Zone": "" // string peer zone for caller
- },
- "span.kind": "server", // string client | server
- "system": "grpc" // string
-
- "custom_field": "custom_value", // string user defined field
- "custom_tags.int": 1337, // int user defined tag on the ctx
- "custom_tags.string": "something", // string user defined tag on the ctx
- }
+Please see examples and tests for examples of use.
-*Payload Interceptor*
-Below is a JSON formatted example of a log that would be logged by the payload interceptor:
-
- {
- "level": "info", // string logrus log levels
- "msg": "client request payload logged as grpc.request.content", // string log message
-
- "grpc.request.content": { // object content of RPC request
- "value": "something", // string defined by caller
- "sleepTimeMs": 9999 // int defined by caller
- },
- "grpc.method": "Ping", // string method being called
- "grpc.service": "mwitkow.testproto.TestService", // string service being called
- "span.kind": "client", // string client | server
- "system": "grpc" // string
- }
+#### Example:
-Note - due to implementation ZAP differs from Logrus in the "grpc.request.content" object by having an inner "msg" object.
+<details>
+<summary>Click to expand code.</summary>
-Please see examples and tests for examples of use.
+```go
+x := func(ctx context.Context, ping *pb_testproto.PingRequest) (*pb_testproto.PingResponse, error) {
+ // Add fields the ctxtags of the request which will be added to all extracted loggers.
+ grpc_ctxtags.Extract(ctx).Set("custom_tags.string", "something").Set("custom_tags.int", 1337)
+ // Extract a request-scoped zap.Logger and log a message.
+ grpc_logrus.Extract(ctx).Info("some ping")
+ return &pb_testproto.PingResponse{Value: ping.Value}, nil
+ }
+ return x
+```
+
+</details>
#### Example:
@@ -79,24 +49,25 @@ Please see examples and tests for examples of use.
```go
// Logrus entry is used, allowing pre-definition of certain fields by the user.
-logrusEntry := logrus.NewEntry(logrusLogger)
-// Shared options for the logger, with a custom gRPC code to log level function.
-opts := []grpc_logrus.Option{
- grpc_logrus.WithLevels(customFunc),
-}
-// Make sure that log statements internal to gRPC library are logged using the logrus Logger as well.
-grpc_logrus.ReplaceGrpcLogger(logrusEntry)
-// Create a server, make sure we put the grpc_ctxtags context before everything else.
-_ = grpc.NewServer(
- grpc_middleware.WithUnaryServerChain(
- grpc_ctxtags.UnaryServerInterceptor(grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.CodeGenRequestFieldExtractor)),
- grpc_logrus.UnaryServerInterceptor(logrusEntry, opts...),
- ),
- grpc_middleware.WithStreamServerChain(
- grpc_ctxtags.StreamServerInterceptor(grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.CodeGenRequestFieldExtractor)),
- grpc_logrus.StreamServerInterceptor(logrusEntry, opts...),
- ),
-)
+ logrusEntry := logrus.NewEntry(logrusLogger)
+ // Shared options for the logger, with a custom gRPC code to log level function.
+ opts := []grpc_logrus.Option{
+ grpc_logrus.WithLevels(customFunc),
+ }
+ // Make sure that log statements internal to gRPC library are logged using the zapLogger as well.
+ grpc_logrus.ReplaceGrpcLogger(logrusEntry)
+ // Create a server, make sure we put the grpc_ctxtags context before everything else.
+ server := grpc.NewServer(
+ grpc_middleware.WithUnaryServerChain(
+ grpc_ctxtags.UnaryServerInterceptor(grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.CodeGenRequestFieldExtractor)),
+ grpc_logrus.UnaryServerInterceptor(logrusEntry, opts...),
+ ),
+ grpc_middleware.WithStreamServerChain(
+ grpc_ctxtags.StreamServerInterceptor(grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.CodeGenRequestFieldExtractor)),
+ grpc_logrus.StreamServerInterceptor(logrusEntry, opts...),
+ ),
+ )
+ return server
```
</details>
@@ -108,36 +79,36 @@ _ = grpc.NewServer(
```go
// Logrus entry is used, allowing pre-definition of certain fields by the user.
-logrusEntry := logrus.NewEntry(logrusLogger)
-// Shared options for the logger, with a custom duration to log field function.
-opts := []grpc_logrus.Option{
- grpc_logrus.WithDurationField(func(duration time.Duration) (key string, value interface{}) {
- return "grpc.time_ns", duration.Nanoseconds()
- }),
-}
-_ = grpc.NewServer(
- grpc_middleware.WithUnaryServerChain(
- grpc_ctxtags.UnaryServerInterceptor(),
- grpc_logrus.UnaryServerInterceptor(logrusEntry, opts...),
- ),
- grpc_middleware.WithStreamServerChain(
- grpc_ctxtags.StreamServerInterceptor(),
- grpc_logrus.StreamServerInterceptor(logrusEntry, opts...),
- ),
-)
+ logrusEntry := logrus.NewEntry(logrusLogger)
+ // Shared options for the logger, with a custom duration to log field function.
+ opts := []grpc_logrus.Option{
+ grpc_logrus.WithDurationField(func(duration time.Duration) (key string, value interface{}) {
+ return "grpc.time_ns", duration.Nanoseconds()
+ }),
+ }
+ server := grpc.NewServer(
+ grpc_middleware.WithUnaryServerChain(
+ grpc_ctxtags.UnaryServerInterceptor(),
+ grpc_logrus.UnaryServerInterceptor(logrusEntry, opts...),
+ ),
+ grpc_middleware.WithStreamServerChain(
+ grpc_ctxtags.StreamServerInterceptor(),
+ grpc_logrus.StreamServerInterceptor(logrusEntry, opts...),
+ ),
+ )
+ return server
```
</details>
## <a name="pkg-imports">Imported Packages</a>
+- github.com/sirupsen/logrus
- [github.com/golang/protobuf/jsonpb](https://godoc.org/github.com/golang/protobuf/jsonpb)
- [github.com/golang/protobuf/proto](https://godoc.org/github.com/golang/protobuf/proto)
- [github.com/grpc-ecosystem/go-grpc-middleware](./../..)
- [github.com/grpc-ecosystem/go-grpc-middleware/logging](./..)
-- [github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus](./ctxlogrus)
-- [github.com/grpc-ecosystem/go-grpc-middleware/tags/logrus](./../../tags/logrus)
-- [github.com/sirupsen/logrus](https://godoc.org/github.com/sirupsen/logrus)
+- [github.com/grpc-ecosystem/go-grpc-middleware/tags](./../../tags)
- [golang.org/x/net/context](https://godoc.org/golang.org/x/net/context)
- [google.golang.org/grpc](https://godoc.org/google.golang.org/grpc)
- [google.golang.org/grpc/codes](https://godoc.org/google.golang.org/grpc/codes)
@@ -145,7 +116,6 @@ _ = grpc.NewServer(
## <a name="pkg-index">Index</a>
* [Variables](#pkg-variables)
-* [func AddFields(ctx context.Context, fields logrus.Fields)](#AddFields)
* [func DefaultClientCodeToLevel(code codes.Code) logrus.Level](#DefaultClientCodeToLevel)
* [func DefaultCodeToLevel(code codes.Code) logrus.Level](#DefaultCodeToLevel)
* [func DurationToDurationField(duration time.Duration) (key string, value interface{})](#DurationToDurationField)
@@ -164,18 +134,16 @@ _ = grpc.NewServer(
* [type DurationToField](#DurationToField)
* [type Option](#Option)
* [func WithCodes(f grpc\_logging.ErrorToCode) Option](#WithCodes)
- * [func WithDecider(f grpc\_logging.Decider) Option](#WithDecider)
* [func WithDurationField(f DurationToField) Option](#WithDurationField)
* [func WithLevels(f CodeToLevel) Option](#WithLevels)
#### <a name="pkg-examples">Examples</a>
-* [Extract (Unary)](#example_Extract_unary)
-* [WithDecider](#example_WithDecider)
+* [Package (HandlerUsageUnaryPing)](#example__handlerUsageUnaryPing)
* [Package (Initialization)](#example__initialization)
* [Package (InitializationWithDurationFieldOverride)](#example__initializationWithDurationFieldOverride)
#### <a name="pkg-files">Package files</a>
-[client_interceptors.go](./client_interceptors.go) [context.go](./context.go) [doc.go](./doc.go) [grpclogger.go](./grpclogger.go) [options.go](./options.go) [payload_interceptors.go](./payload_interceptors.go) [server_interceptors.go](./server_interceptors.go)
+[client_interceptors.go](./client_interceptors.go) [context.go](./context.go) [doc.go](./doc.go) [grpclogger.go](./grpclogger.go) [noop.go](./noop.go) [options.go](./options.go) [payload_interceptors.go](./payload_interceptors.go) [server_interceptors.go](./server_interceptors.go)
## <a name="pkg-variables">Variables</a>
``` go
@@ -194,90 +162,66 @@ DefaultDurationToField is the default implementation of converting request durat
``` go
var (
- // JsonPbMarshaller is the marshaller used for serializing protobuf messages.
+ // JsonPBMarshaller is the marshaller used for serializing protobuf messages.
JsonPbMarshaller = &jsonpb.Marshaler{}
)
```
-## <a name="AddFields">func</a> [AddFields](./context.go#L11)
-``` go
-func AddFields(ctx context.Context, fields logrus.Fields)
-```
-AddFields adds logrus fields to the logger.
-Deprecated: should use the ctxlogrus.Extract instead
-
-## <a name="DefaultClientCodeToLevel">func</a> [DefaultClientCodeToLevel](./options.go#L129)
+## <a name="DefaultClientCodeToLevel">func</a> [DefaultClientCodeToLevel](./options.go#L120)
``` go
func DefaultClientCodeToLevel(code codes.Code) logrus.Level
```
DefaultClientCodeToLevel is the default implementation of gRPC return codes to log levels for client side.
-## <a name="DefaultCodeToLevel">func</a> [DefaultCodeToLevel](./options.go#L87)
+## <a name="DefaultCodeToLevel">func</a> [DefaultCodeToLevel](./options.go#L78)
``` go
func DefaultCodeToLevel(code codes.Code) logrus.Level
```
DefaultCodeToLevel is the default implementation of gRPC return codes to log levels for server side.
-## <a name="DurationToDurationField">func</a> [DurationToDurationField](./options.go#L179)
+## <a name="DurationToDurationField">func</a> [DurationToDurationField](./options.go#L170)
``` go
func DurationToDurationField(duration time.Duration) (key string, value interface{})
```
DurationToDurationField uses the duration value to log the request duration.
-## <a name="DurationToTimeMillisField">func</a> [DurationToTimeMillisField](./options.go#L174)
+## <a name="DurationToTimeMillisField">func</a> [DurationToTimeMillisField](./options.go#L165)
``` go
func DurationToTimeMillisField(duration time.Duration) (key string, value interface{})
```
DurationToTimeMillisField converts the duration to milliseconds and uses the key `grpc.time_ms`.
-## <a name="Extract">func</a> [Extract](./context.go#L17)
+## <a name="Extract">func</a> [Extract](./context.go#L22)
``` go
func Extract(ctx context.Context) *logrus.Entry
```
Extract takes the call-scoped logrus.Entry from grpc_logrus middleware.
-Deprecated: should use the ctxlogrus.Extract instead
-#### Example:
+If the grpc_logrus middleware wasn't used, a no-op `logrus.Entry` is returned. This makes it safe to
+use regardless.
-<details>
-<summary>Click to expand code.</summary>
-
-```go
-_ = func(ctx context.Context, ping *pb_testproto.PingRequest) (*pb_testproto.PingResponse, error) {
- // Add fields the ctxtags of the request which will be added to all extracted loggers.
- grpc_ctxtags.Extract(ctx).Set("custom_tags.string", "something").Set("custom_tags.int", 1337)
- // Extract a single request-scoped logrus.Logger and log messages.
- l := ctx_logrus.Extract(ctx)
- l.Info("some ping")
- l.Info("another ping")
- return &pb_testproto.PingResponse{Value: ping.Value}, nil
-}
-```
-
-</details>
-
-## <a name="PayloadStreamClientInterceptor">func</a> [PayloadStreamClientInterceptor](./payload_interceptors.go#L74)
+## <a name="PayloadStreamClientInterceptor">func</a> [PayloadStreamClientInterceptor](./payload_interceptors.go#L77)
``` go
func PayloadStreamClientInterceptor(entry *logrus.Entry, decider grpc_logging.ClientPayloadLoggingDecider) grpc.StreamClientInterceptor
```
-PayloadStreamClientInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
+PayloadStreamServerInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
-## <a name="PayloadStreamServerInterceptor">func</a> [PayloadStreamServerInterceptor](./payload_interceptors.go#L45)
+## <a name="PayloadStreamServerInterceptor">func</a> [PayloadStreamServerInterceptor](./payload_interceptors.go#L48)
``` go
func PayloadStreamServerInterceptor(entry *logrus.Entry, decider grpc_logging.ServerPayloadLoggingDecider) grpc.StreamServerInterceptor
```
-PayloadStreamServerInterceptor returns a new server server interceptors that logs the payloads of requests.
+PayloadUnaryServerInterceptor returns a new server server interceptors that logs the payloads of requests.
This *only* works when placed *after* the `grpc_logrus.StreamServerInterceptor`. However, the logging can be done to a
separate instance of the logger.
-## <a name="PayloadUnaryClientInterceptor">func</a> [PayloadUnaryClientInterceptor](./payload_interceptors.go#L58)
+## <a name="PayloadUnaryClientInterceptor">func</a> [PayloadUnaryClientInterceptor](./payload_interceptors.go#L61)
``` go
func PayloadUnaryClientInterceptor(entry *logrus.Entry, decider grpc_logging.ClientPayloadLoggingDecider) grpc.UnaryClientInterceptor
```
PayloadUnaryClientInterceptor returns a new unary client interceptor that logs the paylods of requests and responses.
-## <a name="PayloadUnaryServerInterceptor">func</a> [PayloadUnaryServerInterceptor](./payload_interceptors.go#L25)
+## <a name="PayloadUnaryServerInterceptor">func</a> [PayloadUnaryServerInterceptor](./payload_interceptors.go#L28)
``` go
func PayloadUnaryServerInterceptor(entry *logrus.Entry, decider grpc_logging.ServerPayloadLoggingDecider) grpc.UnaryServerInterceptor
```
@@ -299,7 +243,7 @@ func StreamClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamCli
```
StreamServerInterceptor returns a new streaming client interceptor that optionally logs the execution of external gRPC calls.
-## <a name="StreamServerInterceptor">func</a> [StreamServerInterceptor](./server_interceptors.go#L58)
+## <a name="StreamServerInterceptor">func</a> [StreamServerInterceptor](./server_interceptors.go#L50)
``` go
func StreamServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamServerInterceptor
```
@@ -311,77 +255,42 @@ func UnaryClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryClien
```
UnaryClientInterceptor returns a new unary client interceptor that optionally logs the execution of external gRPC calls.
-## <a name="UnaryServerInterceptor">func</a> [UnaryServerInterceptor](./server_interceptors.go#L26)
+## <a name="UnaryServerInterceptor">func</a> [UnaryServerInterceptor](./server_interceptors.go#L25)
``` go
func UnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServerInterceptor
```
-UnaryServerInterceptor returns a new unary server interceptors that adds logrus.Entry to the context.
+PayloadUnaryServerInterceptor returns a new unary server interceptors that adds logrus.Entry to the context.
-## <a name="CodeToLevel">type</a> [CodeToLevel](./options.go#L53)
+## <a name="CodeToLevel">type</a> [CodeToLevel](./options.go#L51)
``` go
type CodeToLevel func(code codes.Code) logrus.Level
```
CodeToLevel function defines the mapping between gRPC return codes and interceptor log level.
-## <a name="DurationToField">type</a> [DurationToField](./options.go#L56)
+## <a name="DurationToField">type</a> [DurationToField](./options.go#L54)
``` go
type DurationToField func(duration time.Duration) (key string, value interface{})
```
DurationToField function defines how to produce duration fields for logging
-## <a name="Option">type</a> [Option](./options.go#L50)
+## <a name="Option">type</a> [Option](./options.go#L48)
``` go
type Option func(*options)
```
-### <a name="WithCodes">func</a> [WithCodes](./options.go#L73)
+### <a name="WithCodes">func</a> [WithCodes](./options.go#L64)
``` go
func WithCodes(f grpc_logging.ErrorToCode) Option
```
WithCodes customizes the function for mapping errors to error codes.
-### <a name="WithDecider">func</a> [WithDecider](./options.go#L59)
-``` go
-func WithDecider(f grpc_logging.Decider) Option
-```
-WithDecider customizes the function for deciding if the gRPC interceptor logs should log.
-
-#### Example:
-
-<details>
-<summary>Click to expand code.</summary>
-
-```go
-opts := []grpc_logrus.Option{
- grpc_logrus.WithDecider(func(methodFullName string, err error) bool {
- // will not log gRPC calls if it was a call to healthcheck and no error was raised
- if err == nil && methodFullName == "blah.foo.healthcheck" {
- return false
- }
-
- // by default you will log all calls
- return true
- }),
-}
-
-_ = []grpc.ServerOption{
- grpc_middleware.WithStreamServerChain(
- grpc_ctxtags.StreamServerInterceptor(),
- grpc_logrus.StreamServerInterceptor(logrus.NewEntry(logrus.New()), opts...)),
- grpc_middleware.WithUnaryServerChain(
- grpc_ctxtags.UnaryServerInterceptor(),
- grpc_logrus.UnaryServerInterceptor(logrus.NewEntry(logrus.New()), opts...)),
-}
-```
-
-</details>
-### <a name="WithDurationField">func</a> [WithDurationField](./options.go#L80)
+### <a name="WithDurationField">func</a> [WithDurationField](./options.go#L71)
``` go
func WithDurationField(f DurationToField) Option
```
WithDurationField customizes the function for mapping request durations to log fields.
-### <a name="WithLevels">func</a> [WithLevels](./options.go#L66)
+### <a name="WithLevels">func</a> [WithLevels](./options.go#L57)
``` go
func WithLevels(f CodeToLevel) Option
```
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/README.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/README.md
index 7a1bb9394..ba136f195 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/README.md
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/README.md
@@ -12,65 +12,35 @@
It accepts a user-configured `logrus.Entry` that will be used for logging completed gRPC calls. The same
`logrus.Entry` will be used for logging completed gRPC calls, and be populated into the `context.Context` passed into gRPC handler code.
-On calling `StreamServerInterceptor` or `UnaryServerInterceptor` this logging middleware will add gRPC call information
-to the ctx so that it will be present on subsequent use of the `ctxlogrus` logger.
+You can use `Extract` to log into a request-scoped `logrus.Entry` instance in your handler code. The fields set on the
+logger correspond to the grpc_ctxtags.Tags attached to the context.
This package also implements request and response *payload* logging, both for server-side and client-side. These will be
-logged as structured `jsonpb` fields for every message received/sent (both unary and streaming). For that please use
+logged as structured `jsonbp` fields for every message received/sent (both unary and streaming). For that please use
`Payload*Interceptor` functions for that. Please note that the user-provided function that determines whetether to log
the full request/response payload needs to be written with care, this can significantly slow down gRPC.
-If a deadline is present on the gRPC request the grpc.request.deadline tag is populated when the request begins. grpc.request.deadline
-is a string representing the time (RFC3339) when the current call will expire.
-
Logrus can also be made as a backend for gRPC library internals. For that use `ReplaceGrpcLogger`.
-*Server Interceptor*
-Below is a JSON formatted example of a log that would be logged by the server interceptor:
-
- {
- "level": "info", // string logrus log levels
- "msg": "finished unary call", // string log message
- "grpc.code": "OK", // string grpc status code
- "grpc.method": "Ping", // string method name
- "grpc.service": "mwitkow.testproto.TestService", // string full name of the called service
- "grpc.start_time": "2006-01-02T15:04:05Z07:00", // string RFC3339 representation of the start time
- "grpc.request.deadline": "2006-01-02T15:04:05Z07:00", // string RFC3339 deadline of the current request if supplied
- "grpc.request.value": "something", // string value on the request
- "grpc.time_ms": 1.234, // float32 run time of the call in ms
- "peer.address": {
- "IP": "127.0.0.1", // string IP address of calling party
- "Port": 60216, // int port call is coming in on
- "Zone": "" // string peer zone for caller
- },
- "span.kind": "server", // string client | server
- "system": "grpc" // string
-
- "custom_field": "custom_value", // string user defined field
- "custom_tags.int": 1337, // int user defined tag on the ctx
- "custom_tags.string": "something", // string user defined tag on the ctx
- }
+Please see examples and tests for examples of use.
-*Payload Interceptor*
-Below is a JSON formatted example of a log that would be logged by the payload interceptor:
-
- {
- "level": "info", // string logrus log levels
- "msg": "client request payload logged as grpc.request.content", // string log message
-
- "grpc.request.content": { // object content of RPC request
- "value": "something", // string defined by caller
- "sleepTimeMs": 9999 // int defined by caller
- },
- "grpc.method": "Ping", // string method being called
- "grpc.service": "mwitkow.testproto.TestService", // string service being called
- "span.kind": "client", // string client | server
- "system": "grpc" // string
- }
+#### Example:
-Note - due to implementation ZAP differs from Logrus in the "grpc.request.content" object by having an inner "msg" object.
+<details>
+<summary>Click to expand code.</summary>
-Please see examples and tests for examples of use.
+```go
+x := func(ctx context.Context, ping *pb_testproto.PingRequest) (*pb_testproto.PingResponse, error) {
+ // Add fields the ctxtags of the request which will be added to all extracted loggers.
+ grpc_ctxtags.Extract(ctx).Set("custom_tags.string", "something").Set("custom_tags.int", 1337)
+ // Extract a request-scoped zap.Logger and log a message.
+ grpc_logrus.Extract(ctx).Info("some ping")
+ return &pb_testproto.PingResponse{Value: ping.Value}, nil
+ }
+ return x
+```
+
+</details>
#### Example:
@@ -79,24 +49,25 @@ Please see examples and tests for examples of use.
```go
// Logrus entry is used, allowing pre-definition of certain fields by the user.
-logrusEntry := logrus.NewEntry(logrusLogger)
-// Shared options for the logger, with a custom gRPC code to log level function.
-opts := []grpc_logrus.Option{
- grpc_logrus.WithLevels(customFunc),
-}
-// Make sure that log statements internal to gRPC library are logged using the logrus Logger as well.
-grpc_logrus.ReplaceGrpcLogger(logrusEntry)
-// Create a server, make sure we put the grpc_ctxtags context before everything else.
-_ = grpc.NewServer(
- grpc_middleware.WithUnaryServerChain(
- grpc_ctxtags.UnaryServerInterceptor(grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.CodeGenRequestFieldExtractor)),
- grpc_logrus.UnaryServerInterceptor(logrusEntry, opts...),
- ),
- grpc_middleware.WithStreamServerChain(
- grpc_ctxtags.StreamServerInterceptor(grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.CodeGenRequestFieldExtractor)),
- grpc_logrus.StreamServerInterceptor(logrusEntry, opts...),
- ),
-)
+ logrusEntry := logrus.NewEntry(logrusLogger)
+ // Shared options for the logger, with a custom gRPC code to log level function.
+ opts := []grpc_logrus.Option{
+ grpc_logrus.WithLevels(customFunc),
+ }
+ // Make sure that log statements internal to gRPC library are logged using the zapLogger as well.
+ grpc_logrus.ReplaceGrpcLogger(logrusEntry)
+ // Create a server, make sure we put the grpc_ctxtags context before everything else.
+ server := grpc.NewServer(
+ grpc_middleware.WithUnaryServerChain(
+ grpc_ctxtags.UnaryServerInterceptor(grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.CodeGenRequestFieldExtractor)),
+ grpc_logrus.UnaryServerInterceptor(logrusEntry, opts...),
+ ),
+ grpc_middleware.WithStreamServerChain(
+ grpc_ctxtags.StreamServerInterceptor(grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.CodeGenRequestFieldExtractor)),
+ grpc_logrus.StreamServerInterceptor(logrusEntry, opts...),
+ ),
+ )
+ return server
```
</details>
@@ -108,36 +79,36 @@ _ = grpc.NewServer(
```go
// Logrus entry is used, allowing pre-definition of certain fields by the user.
-logrusEntry := logrus.NewEntry(logrusLogger)
-// Shared options for the logger, with a custom duration to log field function.
-opts := []grpc_logrus.Option{
- grpc_logrus.WithDurationField(func(duration time.Duration) (key string, value interface{}) {
- return "grpc.time_ns", duration.Nanoseconds()
- }),
-}
-_ = grpc.NewServer(
- grpc_middleware.WithUnaryServerChain(
- grpc_ctxtags.UnaryServerInterceptor(),
- grpc_logrus.UnaryServerInterceptor(logrusEntry, opts...),
- ),
- grpc_middleware.WithStreamServerChain(
- grpc_ctxtags.StreamServerInterceptor(),
- grpc_logrus.StreamServerInterceptor(logrusEntry, opts...),
- ),
-)
+ logrusEntry := logrus.NewEntry(logrusLogger)
+ // Shared options for the logger, with a custom duration to log field function.
+ opts := []grpc_logrus.Option{
+ grpc_logrus.WithDurationField(func(duration time.Duration) (key string, value interface{}) {
+ return "grpc.time_ns", duration.Nanoseconds()
+ }),
+ }
+ server := grpc.NewServer(
+ grpc_middleware.WithUnaryServerChain(
+ grpc_ctxtags.UnaryServerInterceptor(),
+ grpc_logrus.UnaryServerInterceptor(logrusEntry, opts...),
+ ),
+ grpc_middleware.WithStreamServerChain(
+ grpc_ctxtags.StreamServerInterceptor(),
+ grpc_logrus.StreamServerInterceptor(logrusEntry, opts...),
+ ),
+ )
+ return server
```
</details>
## <a name="pkg-imports">Imported Packages</a>
+- github.com/sirupsen/logrus
- [github.com/golang/protobuf/jsonpb](https://godoc.org/github.com/golang/protobuf/jsonpb)
- [github.com/golang/protobuf/proto](https://godoc.org/github.com/golang/protobuf/proto)
- [github.com/grpc-ecosystem/go-grpc-middleware](./../..)
- [github.com/grpc-ecosystem/go-grpc-middleware/logging](./..)
-- [github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus](./ctxlogrus)
-- [github.com/grpc-ecosystem/go-grpc-middleware/tags/logrus](./../../tags/logrus)
-- [github.com/sirupsen/logrus](https://godoc.org/github.com/sirupsen/logrus)
+- [github.com/grpc-ecosystem/go-grpc-middleware/tags](./../../tags)
- [golang.org/x/net/context](https://godoc.org/golang.org/x/net/context)
- [google.golang.org/grpc](https://godoc.org/google.golang.org/grpc)
- [google.golang.org/grpc/codes](https://godoc.org/google.golang.org/grpc/codes)
@@ -145,7 +116,6 @@ _ = grpc.NewServer(
## <a name="pkg-index">Index</a>
* [Variables](#pkg-variables)
-* [func AddFields(ctx context.Context, fields logrus.Fields)](#AddFields)
* [func DefaultClientCodeToLevel(code codes.Code) logrus.Level](#DefaultClientCodeToLevel)
* [func DefaultCodeToLevel(code codes.Code) logrus.Level](#DefaultCodeToLevel)
* [func DurationToDurationField(duration time.Duration) (key string, value interface{})](#DurationToDurationField)
@@ -164,18 +134,16 @@ _ = grpc.NewServer(
* [type DurationToField](#DurationToField)
* [type Option](#Option)
* [func WithCodes(f grpc\_logging.ErrorToCode) Option](#WithCodes)
- * [func WithDecider(f grpc\_logging.Decider) Option](#WithDecider)
* [func WithDurationField(f DurationToField) Option](#WithDurationField)
* [func WithLevels(f CodeToLevel) Option](#WithLevels)
#### <a name="pkg-examples">Examples</a>
-* [Extract (Unary)](#example_Extract_unary)
-* [WithDecider](#example_WithDecider)
+* [Package (HandlerUsageUnaryPing)](#example__handlerUsageUnaryPing)
* [Package (Initialization)](#example__initialization)
* [Package (InitializationWithDurationFieldOverride)](#example__initializationWithDurationFieldOverride)
#### <a name="pkg-files">Package files</a>
-[client_interceptors.go](./client_interceptors.go) [context.go](./context.go) [doc.go](./doc.go) [grpclogger.go](./grpclogger.go) [options.go](./options.go) [payload_interceptors.go](./payload_interceptors.go) [server_interceptors.go](./server_interceptors.go)
+[client_interceptors.go](./client_interceptors.go) [context.go](./context.go) [doc.go](./doc.go) [grpclogger.go](./grpclogger.go) [noop.go](./noop.go) [options.go](./options.go) [payload_interceptors.go](./payload_interceptors.go) [server_interceptors.go](./server_interceptors.go)
## <a name="pkg-variables">Variables</a>
``` go
@@ -194,90 +162,66 @@ DefaultDurationToField is the default implementation of converting request durat
``` go
var (
- // JsonPbMarshaller is the marshaller used for serializing protobuf messages.
+ // JsonPBMarshaller is the marshaller used for serializing protobuf messages.
JsonPbMarshaller = &jsonpb.Marshaler{}
)
```
-## <a name="AddFields">func</a> [AddFields](./context.go#L11)
-``` go
-func AddFields(ctx context.Context, fields logrus.Fields)
-```
-AddFields adds logrus fields to the logger.
-Deprecated: should use the ctxlogrus.Extract instead
-
-## <a name="DefaultClientCodeToLevel">func</a> [DefaultClientCodeToLevel](./options.go#L129)
+## <a name="DefaultClientCodeToLevel">func</a> [DefaultClientCodeToLevel](./options.go#L120)
``` go
func DefaultClientCodeToLevel(code codes.Code) logrus.Level
```
DefaultClientCodeToLevel is the default implementation of gRPC return codes to log levels for client side.
-## <a name="DefaultCodeToLevel">func</a> [DefaultCodeToLevel](./options.go#L87)
+## <a name="DefaultCodeToLevel">func</a> [DefaultCodeToLevel](./options.go#L78)
``` go
func DefaultCodeToLevel(code codes.Code) logrus.Level
```
DefaultCodeToLevel is the default implementation of gRPC return codes to log levels for server side.
-## <a name="DurationToDurationField">func</a> [DurationToDurationField](./options.go#L179)
+## <a name="DurationToDurationField">func</a> [DurationToDurationField](./options.go#L170)
``` go
func DurationToDurationField(duration time.Duration) (key string, value interface{})
```
DurationToDurationField uses the duration value to log the request duration.
-## <a name="DurationToTimeMillisField">func</a> [DurationToTimeMillisField](./options.go#L174)
+## <a name="DurationToTimeMillisField">func</a> [DurationToTimeMillisField](./options.go#L165)
``` go
func DurationToTimeMillisField(duration time.Duration) (key string, value interface{})
```
DurationToTimeMillisField converts the duration to milliseconds and uses the key `grpc.time_ms`.
-## <a name="Extract">func</a> [Extract](./context.go#L17)
+## <a name="Extract">func</a> [Extract](./context.go#L22)
``` go
func Extract(ctx context.Context) *logrus.Entry
```
Extract takes the call-scoped logrus.Entry from grpc_logrus middleware.
-Deprecated: should use the ctxlogrus.Extract instead
-#### Example:
+If the grpc_logrus middleware wasn't used, a no-op `logrus.Entry` is returned. This makes it safe to
+use regardless.
-<details>
-<summary>Click to expand code.</summary>
-
-```go
-_ = func(ctx context.Context, ping *pb_testproto.PingRequest) (*pb_testproto.PingResponse, error) {
- // Add fields the ctxtags of the request which will be added to all extracted loggers.
- grpc_ctxtags.Extract(ctx).Set("custom_tags.string", "something").Set("custom_tags.int", 1337)
- // Extract a single request-scoped logrus.Logger and log messages.
- l := ctx_logrus.Extract(ctx)
- l.Info("some ping")
- l.Info("another ping")
- return &pb_testproto.PingResponse{Value: ping.Value}, nil
-}
-```
-
-</details>
-
-## <a name="PayloadStreamClientInterceptor">func</a> [PayloadStreamClientInterceptor](./payload_interceptors.go#L74)
+## <a name="PayloadStreamClientInterceptor">func</a> [PayloadStreamClientInterceptor](./payload_interceptors.go#L77)
``` go
func PayloadStreamClientInterceptor(entry *logrus.Entry, decider grpc_logging.ClientPayloadLoggingDecider) grpc.StreamClientInterceptor
```
-PayloadStreamClientInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
+PayloadStreamServerInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
-## <a name="PayloadStreamServerInterceptor">func</a> [PayloadStreamServerInterceptor](./payload_interceptors.go#L45)
+## <a name="PayloadStreamServerInterceptor">func</a> [PayloadStreamServerInterceptor](./payload_interceptors.go#L48)
``` go
func PayloadStreamServerInterceptor(entry *logrus.Entry, decider grpc_logging.ServerPayloadLoggingDecider) grpc.StreamServerInterceptor
```
-PayloadStreamServerInterceptor returns a new server server interceptors that logs the payloads of requests.
+PayloadUnaryServerInterceptor returns a new server server interceptors that logs the payloads of requests.
This *only* works when placed *after* the `grpc_logrus.StreamServerInterceptor`. However, the logging can be done to a
separate instance of the logger.
-## <a name="PayloadUnaryClientInterceptor">func</a> [PayloadUnaryClientInterceptor](./payload_interceptors.go#L58)
+## <a name="PayloadUnaryClientInterceptor">func</a> [PayloadUnaryClientInterceptor](./payload_interceptors.go#L61)
``` go
func PayloadUnaryClientInterceptor(entry *logrus.Entry, decider grpc_logging.ClientPayloadLoggingDecider) grpc.UnaryClientInterceptor
```
PayloadUnaryClientInterceptor returns a new unary client interceptor that logs the paylods of requests and responses.
-## <a name="PayloadUnaryServerInterceptor">func</a> [PayloadUnaryServerInterceptor](./payload_interceptors.go#L25)
+## <a name="PayloadUnaryServerInterceptor">func</a> [PayloadUnaryServerInterceptor](./payload_interceptors.go#L28)
``` go
func PayloadUnaryServerInterceptor(entry *logrus.Entry, decider grpc_logging.ServerPayloadLoggingDecider) grpc.UnaryServerInterceptor
```
@@ -299,7 +243,7 @@ func StreamClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamCli
```
StreamServerInterceptor returns a new streaming client interceptor that optionally logs the execution of external gRPC calls.
-## <a name="StreamServerInterceptor">func</a> [StreamServerInterceptor](./server_interceptors.go#L58)
+## <a name="StreamServerInterceptor">func</a> [StreamServerInterceptor](./server_interceptors.go#L50)
``` go
func StreamServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamServerInterceptor
```
@@ -311,77 +255,42 @@ func UnaryClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryClien
```
UnaryClientInterceptor returns a new unary client interceptor that optionally logs the execution of external gRPC calls.
-## <a name="UnaryServerInterceptor">func</a> [UnaryServerInterceptor](./server_interceptors.go#L26)
+## <a name="UnaryServerInterceptor">func</a> [UnaryServerInterceptor](./server_interceptors.go#L25)
``` go
func UnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServerInterceptor
```
-UnaryServerInterceptor returns a new unary server interceptors that adds logrus.Entry to the context.
+PayloadUnaryServerInterceptor returns a new unary server interceptors that adds logrus.Entry to the context.
-## <a name="CodeToLevel">type</a> [CodeToLevel](./options.go#L53)
+## <a name="CodeToLevel">type</a> [CodeToLevel](./options.go#L51)
``` go
type CodeToLevel func(code codes.Code) logrus.Level
```
CodeToLevel function defines the mapping between gRPC return codes and interceptor log level.
-## <a name="DurationToField">type</a> [DurationToField](./options.go#L56)
+## <a name="DurationToField">type</a> [DurationToField](./options.go#L54)
``` go
type DurationToField func(duration time.Duration) (key string, value interface{})
```
DurationToField function defines how to produce duration fields for logging
-## <a name="Option">type</a> [Option](./options.go#L50)
+## <a name="Option">type</a> [Option](./options.go#L48)
``` go
type Option func(*options)
```
-### <a name="WithCodes">func</a> [WithCodes](./options.go#L73)
+### <a name="WithCodes">func</a> [WithCodes](./options.go#L64)
``` go
func WithCodes(f grpc_logging.ErrorToCode) Option
```
WithCodes customizes the function for mapping errors to error codes.
-### <a name="WithDecider">func</a> [WithDecider](./options.go#L59)
-``` go
-func WithDecider(f grpc_logging.Decider) Option
-```
-WithDecider customizes the function for deciding if the gRPC interceptor logs should log.
-
-#### Example:
-
-<details>
-<summary>Click to expand code.</summary>
-
-```go
-opts := []grpc_logrus.Option{
- grpc_logrus.WithDecider(func(methodFullName string, err error) bool {
- // will not log gRPC calls if it was a call to healthcheck and no error was raised
- if err == nil && methodFullName == "blah.foo.healthcheck" {
- return false
- }
-
- // by default you will log all calls
- return true
- }),
-}
-
-_ = []grpc.ServerOption{
- grpc_middleware.WithStreamServerChain(
- grpc_ctxtags.StreamServerInterceptor(),
- grpc_logrus.StreamServerInterceptor(logrus.NewEntry(logrus.New()), opts...)),
- grpc_middleware.WithUnaryServerChain(
- grpc_ctxtags.UnaryServerInterceptor(),
- grpc_logrus.UnaryServerInterceptor(logrus.NewEntry(logrus.New()), opts...)),
-}
-```
-
-</details>
-### <a name="WithDurationField">func</a> [WithDurationField](./options.go#L80)
+### <a name="WithDurationField">func</a> [WithDurationField](./options.go#L71)
``` go
func WithDurationField(f DurationToField) Option
```
WithDurationField customizes the function for mapping request durations to log fields.
-### <a name="WithLevels">func</a> [WithLevels](./options.go#L66)
+### <a name="WithLevels">func</a> [WithLevels](./options.go#L57)
``` go
func WithLevels(f CodeToLevel) Option
```
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/context.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/context.go
index a39bb7720..f7798483a 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/context.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/context.go
@@ -1,19 +1,34 @@
+// Copyright 2016 Michal Witkowski. All Rights Reserved.
+// See LICENSE for licensing terms.
+
package grpc_logrus
import (
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"github.com/sirupsen/logrus"
+ "github.com/grpc-ecosystem/go-grpc-middleware/tags"
"golang.org/x/net/context"
)
-// AddFields adds logrus fields to the logger.
-// Deprecated: should use the ctxlogrus.Extract instead
-func AddFields(ctx context.Context, fields logrus.Fields) {
- ctxlogrus.AddFields(ctx, fields)
-}
+type ctxMarker struct{}
+
+var (
+ ctxMarkerKey = &ctxMarker{}
+)
// Extract takes the call-scoped logrus.Entry from grpc_logrus middleware.
-// Deprecated: should use the ctxlogrus.Extract instead
+//
+// If the grpc_logrus middleware wasn't used, a no-op `logrus.Entry` is returned. This makes it safe to
+// use regardless.
func Extract(ctx context.Context) *logrus.Entry {
- return ctxlogrus.Extract(ctx)
+ l, ok := ctx.Value(ctxMarkerKey).(*logrus.Entry)
+ if !ok {
+ return logrus.NewEntry(nullLogger)
+ }
+ // Add grpc_ctxtags tags metadata until now.
+ return l.WithFields(logrus.Fields(grpc_ctxtags.Extract(ctx).Values()))
+}
+
+func toContext(ctx context.Context, entry *logrus.Entry) context.Context {
+ return context.WithValue(ctx, ctxMarkerKey, entry)
+
}
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/DOC.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/DOC.md
deleted file mode 100644
index 909180292..000000000
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/DOC.md
+++ /dev/null
@@ -1,93 +0,0 @@
-# ctxlogrus
-`import "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"`
-
-* [Overview](#pkg-overview)
-* [Imported Packages](#pkg-imports)
-* [Index](#pkg-index)
-* [Examples](#pkg-examples)
-
-## <a name="pkg-overview">Overview</a>
-`ctxlogrus` is a ctxlogger that is backed by logrus
-
-It accepts a user-configured `logrus.Logger` that will be used for logging. The same `logrus.Logger` will
-be populated into the `context.Context` passed into gRPC handler code.
-
-You can use `ctx_logrus.Extract` to log into a request-scoped `logrus.Logger` instance in your handler code.
-
-As `ctx_logrus.Extract` will iterate all tags on from `grpc_ctxtags` it is therefore expensive so it is advised that you
-extract once at the start of the function from the context and reuse it for the remainder of the function (see examples).
-
-Please see examples and tests for examples of use.
-
-## <a name="pkg-imports">Imported Packages</a>
-
-- [github.com/grpc-ecosystem/go-grpc-middleware/tags](./../../../tags)
-- [github.com/sirupsen/logrus](https://godoc.org/github.com/sirupsen/logrus)
-- [golang.org/x/net/context](https://godoc.org/golang.org/x/net/context)
-
-## <a name="pkg-index">Index</a>
-* [func AddFields(ctx context.Context, fields logrus.Fields)](#AddFields)
-* [func Extract(ctx context.Context) \*logrus.Entry](#Extract)
-* [func ToContext(ctx context.Context, entry \*logrus.Entry) context.Context](#ToContext)
-
-#### <a name="pkg-examples">Examples</a>
-* [Extract (Unary)](#example_Extract_unary)
-
-#### <a name="pkg-files">Package files</a>
-[context.go](./context.go) [doc.go](./doc.go) [noop.go](./noop.go)
-
-## <a name="AddFields">func</a> [AddFields](./context.go#L21)
-``` go
-func AddFields(ctx context.Context, fields logrus.Fields)
-```
-AddFields adds logrus fields to the logger.
-
-## <a name="Extract">func</a> [Extract](./context.go#L35)
-``` go
-func Extract(ctx context.Context) *logrus.Entry
-```
-Extract takes the call-scoped logrus.Entry from ctx_logrus middleware.
-
-If the ctx_logrus middleware wasn't used, a no-op `logrus.Entry` is returned. This makes it safe to
-use regardless.
-
-#### Example:
-
-<details>
-<summary>Click to expand code.</summary>
-
-```go
-package ctxlogrus_test
-
-import (
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- "github.com/grpc-ecosystem/go-grpc-middleware/tags"
- "github.com/sirupsen/logrus"
- "golang.org/x/net/context"
-)
-
-var logrusLogger *logrus.Logger
-
-// Simple unary handler that adds custom fields to the requests's context. These will be used for all log statements.
-func ExampleExtract_unary() {
- ctx := context.Background()
- // setting tags will be added to the logger as log fields
- grpc_ctxtags.Extract(ctx).Set("custom_tags.string", "something").Set("custom_tags.int", 1337)
- // Extract a single request-scoped logrus.Logger and log messages.
- l := ctxlogrus.Extract(ctx)
- l.Info("some ping")
- l.Info("another ping")
-}
-```
-
-</details>
-
-## <a name="ToContext">func</a> [ToContext](./context.go#L59)
-``` go
-func ToContext(ctx context.Context, entry *logrus.Entry) context.Context
-```
-ToContext adds the logrus.Entry to the context for extraction later.
-Returning the new context that has been created.
-
-- - -
-Generated by [godoc2ghmd](https://github.com/GandalfUK/godoc2ghmd) \ No newline at end of file
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/README.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/README.md
deleted file mode 100644
index fc1d0a922..000000000
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/README.md
+++ /dev/null
@@ -1,58 +0,0 @@
-# ctx_logrus
-`import "github.com/grpc-ecosystem/go-grpc-middleware/tags/logrus"`
-
-* [Overview](#pkg-overview)
-* [Imported Packages](#pkg-imports)
-* [Index](#pkg-index)
-
-## <a name="pkg-overview">Overview</a>
-`ctx_logrus` is a ctxlogger that is backed by logrus
-
-It accepts a user-configured `logrus.Logger` that will be used for logging. The same `logrus.Logger` will
-be populated into the `context.Context` passed into gRPC handler code.
-
-You can use `ctx_logrus.Extract` to log into a request-scoped `logrus.Logger` instance in your handler code.
-
-As `ctx_logrus.Extract` will iterate all tags on from `grpc_ctxtags` it is therefore expensive so it is advised that you
-extract once at the start of the function from the context and reuse it for the remainder of the function (see examples).
-
-Please see examples and tests for examples of use.
-
-## <a name="pkg-imports">Imported Packages</a>
-
-- [github.com/grpc-ecosystem/go-grpc-middleware/tags](./..)
-- [github.com/sirupsen/logrus](https://godoc.org/github.com/sirupsen/logrus)
-- [golang.org/x/net/context](https://godoc.org/golang.org/x/net/context)
-
-## <a name="pkg-index">Index</a>
-* [func AddFields(ctx context.Context, fields logrus.Fields)](#AddFields)
-* [func Extract(ctx context.Context) \*logrus.Entry](#Extract)
-* [func ToContext(ctx context.Context, entry \*logrus.Entry) context.Context](#ToContext)
-
-#### <a name="pkg-files">Package files</a>
-[context.go](./context.go) [doc.go](./doc.go) [noop.go](./noop.go)
-
-## <a name="AddFields">func</a> [AddFields](./context.go#L21)
-``` go
-func AddFields(ctx context.Context, fields logrus.Fields)
-```
-AddFields adds logrus fields to the logger.
-
-## <a name="Extract">func</a> [Extract](./context.go#L35)
-``` go
-func Extract(ctx context.Context) *logrus.Entry
-```
-Extract takes the call-scoped logrus.Entry from ctx_logrus middleware.
-
-If the ctx_logrus middleware wasn't used, a no-op `logrus.Entry` is returned. This makes it safe to
-use regardless.
-
-## <a name="ToContext">func</a> [ToContext](./context.go#L59)
-``` go
-func ToContext(ctx context.Context, entry *logrus.Entry) context.Context
-```
-ToContext adds the logrus.Entry to the context for extraction later.
-Returning the new context that has been created.
-
-- - -
-Generated by [godoc2ghmd](https://github.com/GandalfUK/godoc2ghmd) \ No newline at end of file
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/context.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/context.go
deleted file mode 100644
index ff3e3353d..000000000
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/context.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package ctxlogrus
-
-import (
- "github.com/grpc-ecosystem/go-grpc-middleware/tags"
- "github.com/sirupsen/logrus"
- "golang.org/x/net/context"
-)
-
-type ctxLoggerMarker struct{}
-
-type ctxLogger struct {
- logger *logrus.Entry
- fields logrus.Fields
-}
-
-var (
- ctxLoggerKey = &ctxLoggerMarker{}
-)
-
-// AddFields adds logrus fields to the logger.
-func AddFields(ctx context.Context, fields logrus.Fields) {
- l, ok := ctx.Value(ctxLoggerKey).(*ctxLogger)
- if !ok || l == nil {
- return
- }
- for k, v := range fields {
- l.fields[k] = v
- }
-}
-
-// Extract takes the call-scoped logrus.Entry from ctx_logrus middleware.
-//
-// If the ctx_logrus middleware wasn't used, a no-op `logrus.Entry` is returned. This makes it safe to
-// use regardless.
-func Extract(ctx context.Context) *logrus.Entry {
- l, ok := ctx.Value(ctxLoggerKey).(*ctxLogger)
- if !ok || l == nil {
- return logrus.NewEntry(nullLogger)
- }
-
- fields := logrus.Fields{}
-
- // Add grpc_ctxtags tags metadata until now.
- tags := grpc_ctxtags.Extract(ctx)
- for k, v := range tags.Values() {
- fields[k] = v
- }
-
- // Add logrus fields added until now.
- for k, v := range l.fields {
- fields[k] = v
- }
-
- return l.logger.WithFields(fields)
-}
-
-// ToContext adds the logrus.Entry to the context for extraction later.
-// Returning the new context that has been created.
-func ToContext(ctx context.Context, entry *logrus.Entry) context.Context {
- l := &ctxLogger{
- logger: entry,
- fields: logrus.Fields{},
- }
- return context.WithValue(ctx, ctxLoggerKey, l)
-}
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/doc.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/doc.go
deleted file mode 100644
index 95803fb65..000000000
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/doc.go
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
-`ctxlogrus` is a ctxlogger that is backed by logrus
-
-It accepts a user-configured `logrus.Logger` that will be used for logging. The same `logrus.Logger` will
-be populated into the `context.Context` passed into gRPC handler code.
-
-You can use `ctx_logrus.Extract` to log into a request-scoped `logrus.Logger` instance in your handler code.
-
-As `ctx_logrus.Extract` will iterate all tags on from `grpc_ctxtags` it is therefore expensive so it is advised that you
-extract once at the start of the function from the context and reuse it for the remainder of the function (see examples).
-
-Please see examples and tests for examples of use.
-*/
-package ctxlogrus
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/doc.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/doc.go
index df8785f58..0b91720f4 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/doc.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/doc.go
@@ -1,67 +1,22 @@
+// Copyright 2017 Michal Witkowski. All Rights Reserved.
+// See LICENSE for licensing terms.
+
/*
`grpc_logrus` is a gRPC logging middleware backed by Logrus loggers
It accepts a user-configured `logrus.Entry` that will be used for logging completed gRPC calls. The same
`logrus.Entry` will be used for logging completed gRPC calls, and be populated into the `context.Context` passed into gRPC handler code.
-On calling `StreamServerInterceptor` or `UnaryServerInterceptor` this logging middleware will add gRPC call information
-to the ctx so that it will be present on subsequent use of the `ctxlogrus` logger.
+You can use `Extract` to log into a request-scoped `logrus.Entry` instance in your handler code. The fields set on the
+logger correspond to the grpc_ctxtags.Tags attached to the context.
This package also implements request and response *payload* logging, both for server-side and client-side. These will be
-logged as structured `jsonpb` fields for every message received/sent (both unary and streaming). For that please use
+logged as structured `jsonbp` fields for every message received/sent (both unary and streaming). For that please use
`Payload*Interceptor` functions for that. Please note that the user-provided function that determines whetether to log
the full request/response payload needs to be written with care, this can significantly slow down gRPC.
-If a deadline is present on the gRPC request the grpc.request.deadline tag is populated when the request begins. grpc.request.deadline
-is a string representing the time (RFC3339) when the current call will expire.
-
Logrus can also be made as a backend for gRPC library internals. For that use `ReplaceGrpcLogger`.
-*Server Interceptor*
-Below is a JSON formatted example of a log that would be logged by the server interceptor:
-
- {
- "level": "info", // string logrus log levels
- "msg": "finished unary call", // string log message
- "grpc.code": "OK", // string grpc status code
- "grpc.method": "Ping", // string method name
- "grpc.service": "mwitkow.testproto.TestService", // string full name of the called service
- "grpc.start_time": "2006-01-02T15:04:05Z07:00", // string RFC3339 representation of the start time
- "grpc.request.deadline": "2006-01-02T15:04:05Z07:00", // string RFC3339 deadline of the current request if supplied
- "grpc.request.value": "something", // string value on the request
- "grpc.time_ms": 1.234, // float32 run time of the call in ms
- "peer.address": {
- "IP": "127.0.0.1", // string IP address of calling party
- "Port": 60216, // int port call is coming in on
- "Zone": "" // string peer zone for caller
- },
- "span.kind": "server", // string client | server
- "system": "grpc" // string
-
- "custom_field": "custom_value", // string user defined field
- "custom_tags.int": 1337, // int user defined tag on the ctx
- "custom_tags.string": "something", // string user defined tag on the ctx
- }
-
-*Payload Interceptor*
-Below is a JSON formatted example of a log that would be logged by the payload interceptor:
-
- {
- "level": "info", // string logrus log levels
- "msg": "client request payload logged as grpc.request.content", // string log message
-
- "grpc.request.content": { // object content of RPC request
- "value": "something", // string defined by caller
- "sleepTimeMs": 9999 // int defined by caller
- },
- "grpc.method": "Ping", // string method being called
- "grpc.service": "mwitkow.testproto.TestService", // string service being called
- "span.kind": "client", // string client | server
- "system": "grpc" // string
- }
-
-Note - due to implementation ZAP differs from Logrus in the "grpc.request.content" object by having an inner "msg" object.
-
Please see examples and tests for examples of use.
*/
package grpc_logrus
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/noop.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/noop.go
index 7fcc0f64d..f01324cdd 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus/noop.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/noop.go
@@ -1,4 +1,4 @@
-package ctxlogrus
+package grpc_logrus
import (
"io/ioutil"
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/options.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/options.go
index b2b351893..a5f98b048 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/options.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/options.go
@@ -6,15 +6,14 @@ package grpc_logrus
import (
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging"
"github.com/sirupsen/logrus"
+ "github.com/grpc-ecosystem/go-grpc-middleware/logging"
"google.golang.org/grpc/codes"
)
var (
defaultOptions = &options{
levelFunc: nil,
- shouldLog: grpc_logging.DefaultDeciderMethod,
codeFunc: grpc_logging.DefaultErrorToCode,
durationFunc: DefaultDurationToField,
}
@@ -22,7 +21,6 @@ var (
type options struct {
levelFunc CodeToLevel
- shouldLog grpc_logging.Decider
codeFunc grpc_logging.ErrorToCode
durationFunc DurationToField
}
@@ -55,13 +53,6 @@ type CodeToLevel func(code codes.Code) logrus.Level
// DurationToField function defines how to produce duration fields for logging
type DurationToField func(duration time.Duration) (key string, value interface{})
-// WithDecider customizes the function for deciding if the gRPC interceptor logs should log.
-func WithDecider(f grpc_logging.Decider) Option {
- return func(o *options) {
- o.shouldLog = f
- }
-}
-
// WithLevels customizes the function for mapping gRPC return codes and interceptor log level statements.
func WithLevels(f CodeToLevel) Option {
return func(o *options) {
@@ -181,5 +172,5 @@ func DurationToDurationField(duration time.Duration) (key string, value interfac
}
func durationToMilliseconds(duration time.Duration) float32 {
- return float32(duration.Nanoseconds()/1000) / 1000
+ return float32(duration.Nanoseconds() / 1000 / 1000)
}
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/payload_interceptors.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/payload_interceptors.go
index c0aebc8a7..a0b751b49 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/payload_interceptors.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/payload_interceptors.go
@@ -1,20 +1,23 @@
+// Copyright 2017 Michal Witkowski. All Rights Reserved.
+// See LICENSE for licensing terms.
+
package grpc_logrus
import (
"bytes"
+
"fmt"
+ "github.com/sirupsen/logrus"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/go-grpc-middleware/logging"
- "github.com/grpc-ecosystem/go-grpc-middleware/tags/logrus"
- "github.com/sirupsen/logrus"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
var (
- // JsonPbMarshaller is the marshaller used for serializing protobuf messages.
+ // JsonPBMarshaller is the marshaller used for serializing protobuf messages.
JsonPbMarshaller = &jsonpb.Marshaler{}
)
@@ -28,7 +31,7 @@ func PayloadUnaryServerInterceptor(entry *logrus.Entry, decider grpc_logging.Ser
return handler(ctx, req)
}
// Use the provided logrus.Entry for logging but use the fields from context.
- logEntry := entry.WithFields(ctx_logrus.Extract(ctx).Data)
+ logEntry := entry.WithFields(Extract(ctx).Data)
logProtoMessageAsJson(logEntry, req, "grpc.request.content", "server request payload logged as grpc.request.content field")
resp, err := handler(ctx, req)
if err == nil {
@@ -38,7 +41,7 @@ func PayloadUnaryServerInterceptor(entry *logrus.Entry, decider grpc_logging.Ser
}
}
-// PayloadStreamServerInterceptor returns a new server server interceptors that logs the payloads of requests.
+// PayloadUnaryServerInterceptor returns a new server server interceptors that logs the payloads of requests.
//
// This *only* works when placed *after* the `grpc_logrus.StreamServerInterceptor`. However, the logging can be done to a
// separate instance of the logger.
@@ -70,7 +73,7 @@ func PayloadUnaryClientInterceptor(entry *logrus.Entry, decider grpc_logging.Cli
}
}
-// PayloadStreamClientInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
+// PayloadStreamServerInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
func PayloadStreamClientInterceptor(entry *logrus.Entry, decider grpc_logging.ClientPayloadLoggingDecider) grpc.StreamClientInterceptor {
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
if !decider(ctx, method) {
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/server_interceptors.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/server_interceptors.go
index c3b2c7515..9d770e2c4 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/server_interceptors.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/server_interceptors.go
@@ -1,4 +1,5 @@
-// Copyright (c) Improbable Worlds Ltd, All Rights Reserved
+// Copyright 2017 Michal Witkowski. All Rights Reserved.
+// See LICENSE for licensing terms.
package grpc_logrus
@@ -6,10 +7,8 @@ import (
"path"
"time"
- "github.com/grpc-ecosystem/go-grpc-middleware"
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- "github.com/grpc-ecosystem/go-grpc-middleware/tags/logrus"
"github.com/sirupsen/logrus"
+ "github.com/grpc-ecosystem/go-grpc-middleware"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
@@ -22,21 +21,16 @@ var (
KindField = "span.kind"
)
-// UnaryServerInterceptor returns a new unary server interceptors that adds logrus.Entry to the context.
+// PayloadUnaryServerInterceptor returns a new unary server interceptors that adds logrus.Entry to the context.
func UnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServerInterceptor {
o := evaluateServerOpt(opts)
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
+ newCtx := newLoggerForCall(ctx, entry, info.FullMethod)
startTime := time.Now()
- newCtx := newLoggerForCall(ctx, entry, info.FullMethod, startTime)
-
resp, err := handler(newCtx, req)
-
- if !o.shouldLog(info.FullMethod, err) {
- return resp, err
- }
code := o.codeFunc(err)
level := o.levelFunc(code)
- durField, durVal := o.durationFunc(time.Since(startTime))
+ durField, durVal := o.durationFunc(time.Now().Sub(startTime))
fields := logrus.Fields{
"grpc.code": code.String(),
durField: durVal,
@@ -44,12 +38,10 @@ func UnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServe
if err != nil {
fields[logrus.ErrorKey] = err
}
-
levelLogf(
- ctx_logrus.Extract(newCtx).WithFields(fields), // re-extract logger from newCtx, as it may have extra fields that changed in the holder.
+ Extract(newCtx).WithFields(fields), // re-extract logger from newCtx, as it may have extra fields that changed in the holder.
level,
- "finished unary call with code "+code.String())
-
+ "finished unary call")
return resp, err
}
}
@@ -58,19 +50,15 @@ func UnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServe
func StreamServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamServerInterceptor {
o := evaluateServerOpt(opts)
return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
- startTime := time.Now()
- newCtx := newLoggerForCall(stream.Context(), entry, info.FullMethod, startTime)
+ newCtx := newLoggerForCall(stream.Context(), entry, info.FullMethod)
wrapped := grpc_middleware.WrapServerStream(stream)
wrapped.WrappedContext = newCtx
+ startTime := time.Now()
err := handler(srv, wrapped)
-
- if !o.shouldLog(info.FullMethod, err) {
- return err
- }
code := o.codeFunc(err)
level := o.levelFunc(code)
- durField, durVal := o.durationFunc(time.Since(startTime))
+ durField, durVal := o.durationFunc(time.Now().Sub(startTime))
fields := logrus.Fields{
"grpc.code": code.String(),
durField: durVal,
@@ -78,12 +66,10 @@ func StreamServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamSer
if err != nil {
fields[logrus.ErrorKey] = err
}
-
levelLogf(
- ctx_logrus.Extract(newCtx).WithFields(fields), // re-extract logger from newCtx, as it may have extra fields that changed in the holder.
+ Extract(newCtx).WithFields(fields), // re-extract logger from newCtx, as it may have extra fields that changed in the holder.
level,
- "finished streaming call with code "+code.String())
-
+ "finished streaming call")
return err
}
}
@@ -105,25 +91,15 @@ func levelLogf(entry *logrus.Entry, level logrus.Level, format string, args ...i
}
}
-func newLoggerForCall(ctx context.Context, entry *logrus.Entry, fullMethodString string, start time.Time) context.Context {
+func newLoggerForCall(ctx context.Context, entry *logrus.Entry, fullMethodString string) context.Context {
service := path.Dir(fullMethodString)[1:]
method := path.Base(fullMethodString)
callLog := entry.WithFields(
logrus.Fields{
- SystemField: "grpc",
- KindField: "server",
- "grpc.service": service,
- "grpc.method": method,
- "grpc.start_time": start.Format(time.RFC3339),
+ SystemField: "grpc",
+ KindField: "server",
+ "grpc.service": service,
+ "grpc.method": method,
})
-
- if d, ok := ctx.Deadline(); ok {
- callLog = callLog.WithFields(
- logrus.Fields{
- "grpc.request.deadline": d.Format(time.RFC3339),
- })
- }
-
- callLog = callLog.WithFields(ctx_logrus.Extract(ctx).Data)
- return ctxlogrus.ToContext(ctx, callLog)
+ return toContext(ctx, callLog)
}
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/makefile b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/makefile
deleted file mode 100644
index 3e0f296b6..000000000
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-SHELL="/bin/bash"
-
-GOFILES_NOVENDOR = $(shell go list ./... | grep -v /vendor/)
-
-all: vet fmt docs test
-
-docs:
- ./scripts/docs.sh generate
-
-checkdocs:
- ./scripts/docs.sh check
-
-fmt:
- go fmt $(GOFILES_NOVENDOR)
-
-vet:
- go vet $(GOFILES_NOVENDOR)
-
-test: vet
- ./scripts/test_all.sh
-
-.PHONY: all docs validate test
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/slack.png b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/slack.png
deleted file mode 100644
index cc8f9a68a..000000000
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/slack.png
+++ /dev/null
Binary files differ
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/DOC.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/DOC.md
index 907a59fb8..62ec88118 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/DOC.md
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/DOC.md
@@ -13,12 +13,8 @@
Tags describe information about the request, and can be set and used by other middleware, or handlers. Tags are used
for logging and tracing of requests. Tags are populated both upwards, *and* downwards in the interceptor-handler stack.
-You can automatically extract tags (in `grpc.request.<field_name>`) from request payloads.
-
-For unary and server-streaming methods, pass in the `WithFieldExtractor` option. For client-streams and bidirectional-streams, you can
-use `WithFieldExtractorForInitialReq` which will extract the tags from the first message passed from client to server.
-Note the tags will not be modified for subsequent requests, so this option only makes sense when the initial message
-establishes the meta-data for the stream.
+You can automatically extract tags (in `grpc.request.<field_name>`) from request payloads (in unary and server-streaming)
+by passing in the `WithFieldExtractor` option.
If a user doesn't use the interceptors that initialize the `Tags` object, all operations following from an `Extract(ctx)`
will be no-ops. This is to ensure that code doesn't panic if the interceptors weren't used.
@@ -33,29 +29,13 @@ Tags fields are typed, and shallow and should follow the OpenTracing semantics c
```go
opts := []grpc_ctxtags.Option{
- grpc_ctxtags.WithFieldExtractorForInitialReq(grpc_ctxtags.TagBasedRequestFieldExtractor("log_fields")),
-}
-_ = grpc.NewServer(
- grpc.StreamInterceptor(grpc_ctxtags.StreamServerInterceptor(opts...)),
- grpc.UnaryInterceptor(grpc_ctxtags.UnaryServerInterceptor(opts...)),
-)
-```
-
-</details>
-
-#### Example:
-
-<details>
-<summary>Click to expand code.</summary>
-
-```go
-opts := []grpc_ctxtags.Option{
- grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.TagBasedRequestFieldExtractor("log_fields")),
-}
-_ = grpc.NewServer(
- grpc.StreamInterceptor(grpc_ctxtags.StreamServerInterceptor(opts...)),
- grpc.UnaryInterceptor(grpc_ctxtags.UnaryServerInterceptor(opts...)),
-)
+ grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.TagBasedRequestFieldExtractor("log_fields")),
+ }
+ server := grpc.NewServer(
+ grpc.StreamInterceptor(grpc_ctxtags.StreamServerInterceptor(opts...)),
+ grpc.UnaryInterceptor(grpc_ctxtags.UnaryServerInterceptor(opts...)),
+ )
+ return server
```
</details>
@@ -68,34 +48,25 @@ _ = grpc.NewServer(
- [google.golang.org/grpc/peer](https://godoc.org/google.golang.org/grpc/peer)
## <a name="pkg-index">Index</a>
-* [Variables](#pkg-variables)
* [func CodeGenRequestFieldExtractor(fullMethod string, req interface{}) map[string]interface{}](#CodeGenRequestFieldExtractor)
* [func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor](#StreamServerInterceptor)
* [func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor](#UnaryServerInterceptor)
* [type Option](#Option)
* [func WithFieldExtractor(f RequestFieldExtractorFunc) Option](#WithFieldExtractor)
- * [func WithFieldExtractorForInitialReq(f RequestFieldExtractorFunc) Option](#WithFieldExtractorForInitialReq)
* [type RequestFieldExtractorFunc](#RequestFieldExtractorFunc)
* [func TagBasedRequestFieldExtractor(tagName string) RequestFieldExtractorFunc](#TagBasedRequestFieldExtractor)
* [type Tags](#Tags)
- * [func Extract(ctx context.Context) Tags](#Extract)
+ * [func Extract(ctx context.Context) \*Tags](#Extract)
+ * [func (t \*Tags) Has(key string) bool](#Tags.Has)
+ * [func (t \*Tags) Set(key string, value interface{}) \*Tags](#Tags.Set)
+ * [func (t \*Tags) Values() map[string]interface{}](#Tags.Values)
#### <a name="pkg-examples">Examples</a>
-* [Package (InitialisationWithOptions)](#example__initialisationWithOptions)
* [Package (Initialization)](#example__initialization)
#### <a name="pkg-files">Package files</a>
[context.go](./context.go) [doc.go](./doc.go) [fieldextractor.go](./fieldextractor.go) [interceptors.go](./interceptors.go) [options.go](./options.go)
-## <a name="pkg-variables">Variables</a>
-``` go
-var (
-
- // NoopTags is a trivial, minimum overhead implementation of Tags for which all operations are no-ops.
- NoopTags = &noopTags{}
-)
-```
-
## <a name="CodeGenRequestFieldExtractor">func</a> [CodeGenRequestFieldExtractor](./fieldextractor.go#L23)
``` go
func CodeGenRequestFieldExtractor(fullMethod string, req interface{}) map[string]interface{}
@@ -115,25 +86,16 @@ func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
```
UnaryServerInterceptor returns a new unary server interceptors that sets the values for request tags.
-## <a name="Option">type</a> [Option](./options.go#L26)
+## <a name="Option">type</a> [Option](./options.go#L25)
``` go
type Option func(*options)
```
-### <a name="WithFieldExtractor">func</a> [WithFieldExtractor](./options.go#L30)
+### <a name="WithFieldExtractor">func</a> [WithFieldExtractor](./options.go#L28)
``` go
func WithFieldExtractor(f RequestFieldExtractorFunc) Option
```
-WithFieldExtractor customizes the function for extracting log fields from protobuf messages, for
-unary and server-streamed methods only.
-
-### <a name="WithFieldExtractorForInitialReq">func</a> [WithFieldExtractorForInitialReq](./options.go#L39)
-``` go
-func WithFieldExtractorForInitialReq(f RequestFieldExtractorFunc) Option
-```
-WithFieldExtractorForInitialReq customizes the function for extracting log fields from protobuf messages,
-for all unary and streaming methods. For client-streams and bidirectional-streams, the tags will be
-extracted from the first message from the client.
+WithFieldExtractor customizes the function for extracting log fields from protobuf messages.
## <a name="RequestFieldExtractorFunc">type</a> [RequestFieldExtractorFunc](./fieldextractor.go#L13)
``` go
@@ -147,8 +109,8 @@ Keys and values will be added to the context tags of the request. If there are n
``` go
func TagBasedRequestFieldExtractor(tagName string) RequestFieldExtractorFunc
```
-TagBasedRequestFieldExtractor is a function that relies on Go struct tags to export log fields from requests.
-These are usually coming from a protoc-plugin, such as Gogo protobuf.
+TagedRequestFiledExtractor is a function that relies on Go struct tags to export log fields from requests.
+These are usualy coming from a protoc-plugin, such as Gogo protobuf.
message Metadata {
repeated string tags = 1 [ (gogoproto.moretags) = "log_field:\"meta_tags\"" ];
@@ -156,27 +118,40 @@ These are usually coming from a protoc-plugin, such as Gogo protobuf.
The tagName is configurable using the tagName variable. Here it would be "log_field".
-## <a name="Tags">type</a> [Tags](./context.go#L19-L27)
+## <a name="Tags">type</a> [Tags](./context.go#L15-L17)
``` go
-type Tags interface {
- // Set sets the given key in the metadata tags.
- Set(key string, value interface{}) Tags
- // Has checks if the given key exists.
- Has(key string) bool
- // Values returns a map of key to values.
- // Do not modify the underlying map, please use Set instead.
- Values() map[string]interface{}
+type Tags struct {
+ // contains filtered or unexported fields
}
```
-Tags is the interface used for storing request tags between Context calls.
-The default implementation is *not* thread safe, and should be handled only in the context of the request.
+Tags is the struct used for storing request tags between Context calls.
+This object is *not* thread safe, and should be handled only in the context of the request.
-### <a name="Extract">func</a> [Extract](./context.go#L63)
+### <a name="Extract">func</a> [Extract](./context.go#L39)
``` go
-func Extract(ctx context.Context) Tags
+func Extract(ctx context.Context) *Tags
```
Extracts returns a pre-existing Tags object in the Context.
If the context wasn't set in a tag interceptor, a no-op Tag storage is returned that will *not* be propagated in context.
+### <a name="Tags.Has">func</a> (\*Tags) [Has](./context.go#L26)
+``` go
+func (t *Tags) Has(key string) bool
+```
+Has checks if the given key exists.
+
+### <a name="Tags.Set">func</a> (\*Tags) [Set](./context.go#L20)
+``` go
+func (t *Tags) Set(key string, value interface{}) *Tags
+```
+Set sets the given key in the metadata tags.
+
+### <a name="Tags.Values">func</a> (\*Tags) [Values](./context.go#L33)
+``` go
+func (t *Tags) Values() map[string]interface{}
+```
+Values returns a map of key to values.
+Do not modify the underlying map, please use Set instead.
+
- - -
Generated by [godoc2ghmd](https://github.com/GandalfUK/godoc2ghmd) \ No newline at end of file
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/README.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/README.md
index 907a59fb8..62ec88118 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/README.md
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/README.md
@@ -13,12 +13,8 @@
Tags describe information about the request, and can be set and used by other middleware, or handlers. Tags are used
for logging and tracing of requests. Tags are populated both upwards, *and* downwards in the interceptor-handler stack.
-You can automatically extract tags (in `grpc.request.<field_name>`) from request payloads.
-
-For unary and server-streaming methods, pass in the `WithFieldExtractor` option. For client-streams and bidirectional-streams, you can
-use `WithFieldExtractorForInitialReq` which will extract the tags from the first message passed from client to server.
-Note the tags will not be modified for subsequent requests, so this option only makes sense when the initial message
-establishes the meta-data for the stream.
+You can automatically extract tags (in `grpc.request.<field_name>`) from request payloads (in unary and server-streaming)
+by passing in the `WithFieldExtractor` option.
If a user doesn't use the interceptors that initialize the `Tags` object, all operations following from an `Extract(ctx)`
will be no-ops. This is to ensure that code doesn't panic if the interceptors weren't used.
@@ -33,29 +29,13 @@ Tags fields are typed, and shallow and should follow the OpenTracing semantics c
```go
opts := []grpc_ctxtags.Option{
- grpc_ctxtags.WithFieldExtractorForInitialReq(grpc_ctxtags.TagBasedRequestFieldExtractor("log_fields")),
-}
-_ = grpc.NewServer(
- grpc.StreamInterceptor(grpc_ctxtags.StreamServerInterceptor(opts...)),
- grpc.UnaryInterceptor(grpc_ctxtags.UnaryServerInterceptor(opts...)),
-)
-```
-
-</details>
-
-#### Example:
-
-<details>
-<summary>Click to expand code.</summary>
-
-```go
-opts := []grpc_ctxtags.Option{
- grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.TagBasedRequestFieldExtractor("log_fields")),
-}
-_ = grpc.NewServer(
- grpc.StreamInterceptor(grpc_ctxtags.StreamServerInterceptor(opts...)),
- grpc.UnaryInterceptor(grpc_ctxtags.UnaryServerInterceptor(opts...)),
-)
+ grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.TagBasedRequestFieldExtractor("log_fields")),
+ }
+ server := grpc.NewServer(
+ grpc.StreamInterceptor(grpc_ctxtags.StreamServerInterceptor(opts...)),
+ grpc.UnaryInterceptor(grpc_ctxtags.UnaryServerInterceptor(opts...)),
+ )
+ return server
```
</details>
@@ -68,34 +48,25 @@ _ = grpc.NewServer(
- [google.golang.org/grpc/peer](https://godoc.org/google.golang.org/grpc/peer)
## <a name="pkg-index">Index</a>
-* [Variables](#pkg-variables)
* [func CodeGenRequestFieldExtractor(fullMethod string, req interface{}) map[string]interface{}](#CodeGenRequestFieldExtractor)
* [func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor](#StreamServerInterceptor)
* [func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor](#UnaryServerInterceptor)
* [type Option](#Option)
* [func WithFieldExtractor(f RequestFieldExtractorFunc) Option](#WithFieldExtractor)
- * [func WithFieldExtractorForInitialReq(f RequestFieldExtractorFunc) Option](#WithFieldExtractorForInitialReq)
* [type RequestFieldExtractorFunc](#RequestFieldExtractorFunc)
* [func TagBasedRequestFieldExtractor(tagName string) RequestFieldExtractorFunc](#TagBasedRequestFieldExtractor)
* [type Tags](#Tags)
- * [func Extract(ctx context.Context) Tags](#Extract)
+ * [func Extract(ctx context.Context) \*Tags](#Extract)
+ * [func (t \*Tags) Has(key string) bool](#Tags.Has)
+ * [func (t \*Tags) Set(key string, value interface{}) \*Tags](#Tags.Set)
+ * [func (t \*Tags) Values() map[string]interface{}](#Tags.Values)
#### <a name="pkg-examples">Examples</a>
-* [Package (InitialisationWithOptions)](#example__initialisationWithOptions)
* [Package (Initialization)](#example__initialization)
#### <a name="pkg-files">Package files</a>
[context.go](./context.go) [doc.go](./doc.go) [fieldextractor.go](./fieldextractor.go) [interceptors.go](./interceptors.go) [options.go](./options.go)
-## <a name="pkg-variables">Variables</a>
-``` go
-var (
-
- // NoopTags is a trivial, minimum overhead implementation of Tags for which all operations are no-ops.
- NoopTags = &noopTags{}
-)
-```
-
## <a name="CodeGenRequestFieldExtractor">func</a> [CodeGenRequestFieldExtractor](./fieldextractor.go#L23)
``` go
func CodeGenRequestFieldExtractor(fullMethod string, req interface{}) map[string]interface{}
@@ -115,25 +86,16 @@ func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
```
UnaryServerInterceptor returns a new unary server interceptors that sets the values for request tags.
-## <a name="Option">type</a> [Option](./options.go#L26)
+## <a name="Option">type</a> [Option](./options.go#L25)
``` go
type Option func(*options)
```
-### <a name="WithFieldExtractor">func</a> [WithFieldExtractor](./options.go#L30)
+### <a name="WithFieldExtractor">func</a> [WithFieldExtractor](./options.go#L28)
``` go
func WithFieldExtractor(f RequestFieldExtractorFunc) Option
```
-WithFieldExtractor customizes the function for extracting log fields from protobuf messages, for
-unary and server-streamed methods only.
-
-### <a name="WithFieldExtractorForInitialReq">func</a> [WithFieldExtractorForInitialReq](./options.go#L39)
-``` go
-func WithFieldExtractorForInitialReq(f RequestFieldExtractorFunc) Option
-```
-WithFieldExtractorForInitialReq customizes the function for extracting log fields from protobuf messages,
-for all unary and streaming methods. For client-streams and bidirectional-streams, the tags will be
-extracted from the first message from the client.
+WithFieldExtractor customizes the function for extracting log fields from protobuf messages.
## <a name="RequestFieldExtractorFunc">type</a> [RequestFieldExtractorFunc](./fieldextractor.go#L13)
``` go
@@ -147,8 +109,8 @@ Keys and values will be added to the context tags of the request. If there are n
``` go
func TagBasedRequestFieldExtractor(tagName string) RequestFieldExtractorFunc
```
-TagBasedRequestFieldExtractor is a function that relies on Go struct tags to export log fields from requests.
-These are usually coming from a protoc-plugin, such as Gogo protobuf.
+TagedRequestFiledExtractor is a function that relies on Go struct tags to export log fields from requests.
+These are usualy coming from a protoc-plugin, such as Gogo protobuf.
message Metadata {
repeated string tags = 1 [ (gogoproto.moretags) = "log_field:\"meta_tags\"" ];
@@ -156,27 +118,40 @@ These are usually coming from a protoc-plugin, such as Gogo protobuf.
The tagName is configurable using the tagName variable. Here it would be "log_field".
-## <a name="Tags">type</a> [Tags](./context.go#L19-L27)
+## <a name="Tags">type</a> [Tags](./context.go#L15-L17)
``` go
-type Tags interface {
- // Set sets the given key in the metadata tags.
- Set(key string, value interface{}) Tags
- // Has checks if the given key exists.
- Has(key string) bool
- // Values returns a map of key to values.
- // Do not modify the underlying map, please use Set instead.
- Values() map[string]interface{}
+type Tags struct {
+ // contains filtered or unexported fields
}
```
-Tags is the interface used for storing request tags between Context calls.
-The default implementation is *not* thread safe, and should be handled only in the context of the request.
+Tags is the struct used for storing request tags between Context calls.
+This object is *not* thread safe, and should be handled only in the context of the request.
-### <a name="Extract">func</a> [Extract](./context.go#L63)
+### <a name="Extract">func</a> [Extract](./context.go#L39)
``` go
-func Extract(ctx context.Context) Tags
+func Extract(ctx context.Context) *Tags
```
Extracts returns a pre-existing Tags object in the Context.
If the context wasn't set in a tag interceptor, a no-op Tag storage is returned that will *not* be propagated in context.
+### <a name="Tags.Has">func</a> (\*Tags) [Has](./context.go#L26)
+``` go
+func (t *Tags) Has(key string) bool
+```
+Has checks if the given key exists.
+
+### <a name="Tags.Set">func</a> (\*Tags) [Set](./context.go#L20)
+``` go
+func (t *Tags) Set(key string, value interface{}) *Tags
+```
+Set sets the given key in the metadata tags.
+
+### <a name="Tags.Values">func</a> (\*Tags) [Values](./context.go#L33)
+``` go
+func (t *Tags) Values() map[string]interface{}
+```
+Values returns a map of key to values.
+Do not modify the underlying map, please use Set instead.
+
- - -
Generated by [godoc2ghmd](https://github.com/GandalfUK/godoc2ghmd) \ No newline at end of file
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/context.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/context.go
index 583025ce5..15a1c0b65 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/context.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/context.go
@@ -1,8 +1,6 @@
package grpc_ctxtags
-import (
- "context"
-)
+import "context"
type ctxMarker struct{}
@@ -10,69 +8,42 @@ var (
// ctxMarkerKey is the Context value marker used by *all* logging middleware.
// The logging middleware object must interf
ctxMarkerKey = &ctxMarker{}
- // NoopTags is a trivial, minimum overhead implementation of Tags for which all operations are no-ops.
- NoopTags = &noopTags{}
)
-// Tags is the interface used for storing request tags between Context calls.
-// The default implementation is *not* thread safe, and should be handled only in the context of the request.
-type Tags interface {
- // Set sets the given key in the metadata tags.
- Set(key string, value interface{}) Tags
- // Has checks if the given key exists.
- Has(key string) bool
- // Values returns a map of key to values.
- // Do not modify the underlying map, please use Set instead.
- Values() map[string]interface{}
-}
-
-type mapTags struct {
+// Tags is the struct used for storing request tags between Context calls.
+// This object is *not* thread safe, and should be handled only in the context of the request.
+type Tags struct {
values map[string]interface{}
}
-func (t *mapTags) Set(key string, value interface{}) Tags {
+// Set sets the given key in the metadata tags.
+func (t *Tags) Set(key string, value interface{}) *Tags {
t.values[key] = value
return t
}
-func (t *mapTags) Has(key string) bool {
+// Has checks if the given key exists.
+func (t *Tags) Has(key string) bool {
_, ok := t.values[key]
return ok
}
-func (t *mapTags) Values() map[string]interface{} {
+// Values returns a map of key to values.
+// Do not modify the underlying map, please use Set instead.
+func (t *Tags) Values() map[string]interface{} {
return t.values
}
-type noopTags struct{}
-
-func (t *noopTags) Set(key string, value interface{}) Tags {
- return t
-}
-
-func (t *noopTags) Has(key string) bool {
- return false
-}
-
-func (t *noopTags) Values() map[string]interface{} {
- return nil
-}
-
// Extracts returns a pre-existing Tags object in the Context.
// If the context wasn't set in a tag interceptor, a no-op Tag storage is returned that will *not* be propagated in context.
-func Extract(ctx context.Context) Tags {
- t, ok := ctx.Value(ctxMarkerKey).(Tags)
+func Extract(ctx context.Context) *Tags {
+ t, ok := ctx.Value(ctxMarkerKey).(*Tags)
if !ok {
- return NoopTags
+ return &Tags{values: make(map[string]interface{})}
}
-
return t
}
-func setInContext(ctx context.Context, tags Tags) context.Context {
+func setInContext(ctx context.Context, tags *Tags) context.Context {
return context.WithValue(ctx, ctxMarkerKey, tags)
}
-
-func newTags() Tags {
- return &mapTags{values: make(map[string]interface{})}
-}
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/doc.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/doc.go
index 960638d0f..4e2912fd4 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/doc.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/doc.go
@@ -1,3 +1,6 @@
+// Copyright 2017 Michal Witkowski. All Rights Reserved.
+// See LICENSE for licensing terms.
+
/*
`grpc_ctxtags` adds a Tag object to the context that can be used by other middleware to add context about a request.
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/fieldextractor.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/fieldextractor.go
index 549ff48c8..1d7c1a7fa 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/fieldextractor.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/fieldextractor.go
@@ -32,8 +32,8 @@ func CodeGenRequestFieldExtractor(fullMethod string, req interface{}) map[string
return nil
}
-// TagBasedRequestFieldExtractor is a function that relies on Go struct tags to export log fields from requests.
-// These are usually coming from a protoc-plugin, such as Gogo protobuf.
+// TagedRequestFiledExtractor is a function that relies on Go struct tags to export log fields from requests.
+// These are usualy coming from a protoc-plugin, such as Gogo protobuf.
//
// message Metadata {
// repeated string tags = 1 [ (gogoproto.moretags) = "log_field:\"meta_tags\"" ];
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/interceptors.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/interceptors.go
index 038afd26b..5f6255147 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/interceptors.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/interceptors.go
@@ -56,7 +56,7 @@ func (w *wrappedStream) Context() context.Context {
func (w *wrappedStream) RecvMsg(m interface{}) error {
err := w.ServerStream.RecvMsg(m)
- // We only do log fields extraction on the single-request of a server-side stream.
+ // We only do log fields extraction on the single-reqest of a server-side stream.
if !w.info.IsClientStream || w.opts.requestFieldsFromInitial && w.initial {
w.initial = false
@@ -66,9 +66,9 @@ func (w *wrappedStream) RecvMsg(m interface{}) error {
}
func newTagsForCtx(ctx context.Context) context.Context {
- t := newTags()
+ t := Extract(ctx) // will allocate a new one if it didn't exist.
if peer, ok := peer.FromContext(ctx); ok {
- t.Set("peer.address", peer.Addr.String())
+ t.Set("peer.address", peer.Addr)
}
return setInContext(ctx, t)
}
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/logrus/context.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/logrus/context.go
deleted file mode 100644
index 2596be89f..000000000
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tags/logrus/context.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package ctx_logrus
-
-import (
- "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
- "github.com/sirupsen/logrus"
- "golang.org/x/net/context"
-)
-
-// AddFields adds logrus fields to the logger.
-// Deprecated: should use the ctxlogrus.Extract instead
-func AddFields(ctx context.Context, fields logrus.Fields) {
- ctxlogrus.AddFields(ctx, fields)
-}
-
-// Extract takes the call-scoped logrus.Entry from grpc_logrus middleware.
-// Deprecated: should use the ctxlogrus.Extract instead
-func Extract(ctx context.Context) *logrus.Entry {
- return ctxlogrus.Extract(ctx)
-}
-
-// ToContext adds the logrus.Entry to the context for extraction later.
-// Depricated: should use ctxlogrus.ToContext instead
-func ToContext(ctx context.Context, entry *logrus.Entry) context.Context {
- return ctxlogrus.ToContext(ctx, entry)
-}
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/test_all.sh b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/test_all.sh
new file mode 100755
index 000000000..e1e780080
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/test_all.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+set -e
+echo "" > coverage.txt
+
+for d in $(go list ./... | grep -v vendor); do
+ echo -e "TESTS FOR: for \033[0;35m${d}\033[0m"
+ go test -race -v -coverprofile=profile.coverage.out -covermode=atomic $d
+ if [ -f profile.coverage.out ]; then
+ cat profile.coverage.out >> coverage.txt
+ rm profile.coverage.out
+ fi
+ echo ""
+done
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/util/metautils/DOC.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/util/metautils/DOC.md
index a02cde31e..d93514ce1 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/util/metautils/DOC.md
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/util/metautils/DOC.md
@@ -25,7 +25,7 @@
* [func (m NiceMD) ToOutgoing(ctx context.Context) context.Context](#NiceMD.ToOutgoing)
#### <a name="pkg-files">Package files</a>
-[doc.go](./doc.go) [nicemd.go](./nicemd.go) [single_key.go](./single_key.go)
+[doc.go](./doc.go) [nicemd.go](./nicemd.go) [single_key.go](./single_key.go)
## <a name="NiceMD">type</a> [NiceMD](./nicemd.go#L14)
``` go
@@ -111,4 +111,4 @@ func (m NiceMD) ToOutgoing(ctx context.Context) context.Context
ToOutgoing sets the given NiceMD as a client-side context for dispatching.
- - -
-Generated by [godoc2ghmd](https://github.com/GandalfUK/godoc2ghmd) \ No newline at end of file
+Generated by [godoc2ghmd](https://github.com/GandalfUK/godoc2ghmd)
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/util/metautils/README.md b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/util/metautils/README.md
index a02cde31e..d93514ce1 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/util/metautils/README.md
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/util/metautils/README.md
@@ -25,7 +25,7 @@
* [func (m NiceMD) ToOutgoing(ctx context.Context) context.Context](#NiceMD.ToOutgoing)
#### <a name="pkg-files">Package files</a>
-[doc.go](./doc.go) [nicemd.go](./nicemd.go) [single_key.go](./single_key.go)
+[doc.go](./doc.go) [nicemd.go](./nicemd.go) [single_key.go](./single_key.go)
## <a name="NiceMD">type</a> [NiceMD](./nicemd.go#L14)
``` go
@@ -111,4 +111,4 @@ func (m NiceMD) ToOutgoing(ctx context.Context) context.Context
ToOutgoing sets the given NiceMD as a client-side context for dispatching.
- - -
-Generated by [godoc2ghmd](https://github.com/GandalfUK/godoc2ghmd) \ No newline at end of file
+Generated by [godoc2ghmd](https://github.com/GandalfUK/godoc2ghmd)
diff --git a/vendor/vendor.json b/vendor/vendor.json
index bf5312a38..4d90e06d1 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -107,68 +107,52 @@
"versionExact": "v1.2.0"
},
{
- "checksumSHA1": "5TKR3lamABvUhxkopYnphszS+Xc=",
+ "checksumSHA1": "ThM4ahoRKh7k2b0YqRrxRk7KlEU=",
"path": "github.com/grpc-ecosystem/go-grpc-middleware",
- "revision": "c250d6563d4d4c20252cd865923440e829844f4e",
- "revisionTime": "2018-05-02T09:16:42Z",
- "version": "v1",
- "versionExact": "v1.0.0"
+ "revision": "82921fcf811d228d2fa202bc31238b356bf9f8d5",
+ "revisionTime": "2017-10-20T06:37:31Z"
},
{
- "checksumSHA1": "tvOR7YKj51rBR+j5C/ZyZj6rvYc=",
+ "checksumSHA1": "zsl4yCXK72d8UIEpczA1vPf7RFg=",
"path": "github.com/grpc-ecosystem/go-grpc-middleware/auth",
- "revision": "c250d6563d4d4c20252cd865923440e829844f4e",
- "revisionTime": "2018-05-02T09:16:42Z",
- "version": "v1",
- "versionExact": "v1.0.0"
+ "revision": "82921fcf811d228d2fa202bc31238b356bf9f8d5",
+ "revisionTime": "2017-10-20T06:37:31Z"
},
{
- "checksumSHA1": "YdjXbik3OwU+YwQL7OAzwqAAUjo=",
+ "checksumSHA1": "S3ewTxb4DObPxnizenAS0qq1QvE=",
"path": "github.com/grpc-ecosystem/go-grpc-middleware/logging",
- "revision": "c250d6563d4d4c20252cd865923440e829844f4e",
- "revisionTime": "2018-05-02T09:16:42Z",
- "version": "v1",
- "versionExact": "v1.0.0"
+ "revision": "82921fcf811d228d2fa202bc31238b356bf9f8d5",
+ "revisionTime": "2017-10-20T06:37:31Z"
},
{
- "checksumSHA1": "sRalD4xQkkeydbEmfGhdVC6iy94=",
+ "checksumSHA1": "797n3ROaKPn+F3WbjmBZdvQDGUY=",
"path": "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus",
- "revision": "c250d6563d4d4c20252cd865923440e829844f4e",
- "revisionTime": "2018-05-02T09:16:42Z",
- "version": "v1",
- "versionExact": "v1.0.0"
+ "revision": "82921fcf811d228d2fa202bc31238b356bf9f8d5",
+ "revisionTime": "2017-10-20T06:37:31Z"
},
{
"checksumSHA1": "lyjaDmKU/dk/K4ciP5OUJEzmjfA=",
"path": "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus",
"revision": "c250d6563d4d4c20252cd865923440e829844f4e",
- "revisionTime": "2018-05-02T09:16:42Z",
- "version": "v1",
- "versionExact": "v1.0.0"
+ "revisionTime": "2018-05-02T09:16:42Z"
},
{
- "checksumSHA1": "Rf3QgJeAX2809t/DZvMjZbGHe9U=",
+ "checksumSHA1": "3vb2ftEAl6BEmsi3grb7fIVLdDU=",
"path": "github.com/grpc-ecosystem/go-grpc-middleware/tags",
- "revision": "c250d6563d4d4c20252cd865923440e829844f4e",
- "revisionTime": "2018-05-02T09:16:42Z",
- "version": "v1",
- "versionExact": "v1.0.0"
+ "revision": "82921fcf811d228d2fa202bc31238b356bf9f8d5",
+ "revisionTime": "2017-10-20T06:37:31Z"
},
{
"checksumSHA1": "g5zvkcjKi3oc+BXuqJfMfG2tP+c=",
"path": "github.com/grpc-ecosystem/go-grpc-middleware/tags/logrus",
"revision": "c250d6563d4d4c20252cd865923440e829844f4e",
- "revisionTime": "2018-05-02T09:16:42Z",
- "version": "v1",
- "versionExact": "v1.0.0"
+ "revisionTime": "2018-05-02T09:16:42Z"
},
{
- "checksumSHA1": "L5z1C445GhhQmDKSisTFv754LdU=",
+ "checksumSHA1": "kozQMhxjHOOj3RCE6uKWABiJ4TA=",
"path": "github.com/grpc-ecosystem/go-grpc-middleware/util/metautils",
- "revision": "c250d6563d4d4c20252cd865923440e829844f4e",
- "revisionTime": "2018-05-02T09:16:42Z",
- "version": "v1",
- "versionExact": "v1.0.0"
+ "revision": "82921fcf811d228d2fa202bc31238b356bf9f8d5",
+ "revisionTime": "2017-10-20T06:37:31Z"
},
{
"checksumSHA1": "3iVD2sJv4uYnA8YgkR8yzZiUF7o=",