Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add logging.InjectFields usage description #540

Closed
wants to merge 69 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
4d4c8f9
Initial change for v2.
bwplotka Feb 29, 2020
dfb47b3
Addressed comments.
bwplotka Mar 5, 2020
ce741ac
Merge pull request #276 from grpc-ecosystem/v2-init
bwplotka Mar 5, 2020
41f1280
Updated README with note that it's under development.
bwplotka Mar 5, 2020
542dcc3
Merge pull request #278 from grpc-ecosystem/update-readme
bwplotka Mar 5, 2020
eb2c8a6
Fix typo in field extractor (splices -> slices) (#287) (#289)
bvwells Apr 29, 2020
818c8cf
Moved imports to v2; Moved to Go 1.14.2 (#290)
bwplotka May 1, 2020
55554ba
Formatted code; Added goimports to Makefile, Renamed pb_testproto to …
bwplotka May 1, 2020
2017e41
Fixed providers go modules, examples and consistency. (#292)
bwplotka May 2, 2020
a0e7c73
added example for AuthFuncOverride (#294)
tegk May 12, 2020
4664c92
Added some description of the Makefile in the contributing.md (#298)
yashrsharma44 Jun 3, 2020
e482ad4
Add support for the zerolog logging provider (#299)
irridia Jun 3, 2020
6e2c2ac
proto: fix gogoproto import (#302)
johanbrandhorst Jun 4, 2020
b99e582
Retry dial and connection errors for grpc stream. (#308)
kartlee Jun 17, 2020
880c174
Moved to GH actions; Added lint; Added issue/PR templates. (#296)
bwplotka Jun 18, 2020
61761eb
inline localhost certificate into go file (#318)
bmon Jul 16, 2020
f2e4dcb
Update streaming interceptor example (#322)
G07cha Jul 24, 2020
d07eb4f
Do not stop retrying based on earlier good message from the stream (#…
kartlee Aug 2, 2020
aef62a9
Remove pre-generated certificates from tests (#331)
dmitris Sep 9, 2020
a4fdb5d
add all make target, reword instructions (#335)
dmitris Sep 9, 2020
88c8444
remove 1.12.x from build config for consistency with master (#337)
dmitris Sep 10, 2020
2a8b5ab
[v2] Fix the special case for jaeger format traceid extraction (#340)
nvx Sep 17, 2020
9d12ea6
Fix ctxtags TagBasedRequestFieldExtractor extracting from fields in a…
nvx Sep 18, 2020
73cf2ae
Request Logging (#311)
yashrsharma44 Oct 2, 2020
7d39267
Bug fix for data race (#354)
yashrsharma44 Nov 19, 2020
38f54d9
make ratelimit interface context aware (#367)
xinxiao Nov 28, 2020
9f6bf00
Added an error param for decider method (#372)
yashrsharma44 Dec 7, 2020
08b17eb
[v2] Add skip interceptor (#364)
XSAM Dec 30, 2020
4a659d8
Remove custom chain middleware (#385)
drewwells Jan 20, 2021
ad3d951
Update travis ci badge to Github actions badge. (#384)
drewwells Jan 20, 2021
c1f1e53
Upgraded proto related deps: grpc and protobuf; removed gogo from cor…
bwplotka Jan 22, 2021
6672a20
improve v2 rate-limiter (#380)
MalloZup Jan 22, 2021
468f615
Moved to buf; Added buf lint; Fixed ping service to match standards; …
bwplotka Jan 22, 2021
3ff779b
Added a timer interface (#387)
yashrsharma44 Jan 28, 2021
20b2825
[Rate-limit provider]: Add token bucket implementation of rate-limite…
MalloZup Jan 29, 2021
215af81
Add OpenMetrics(Prometheus) in the provider module (#379)
yashrsharma44 Jan 29, 2021
524ce8f
v2: Client unary interceptor timeout on v2 branch (#330)
instabledesign Mar 26, 2021
0df73fc
add onRetryCallback callback function (#405)
shamil Apr 3, 2021
0c9d258
port to v2 (#418)
danielhochman Apr 23, 2021
f60016a
Refactor metrics interceptor and fix tests (#413)
ash2k Apr 23, 2021
b81999a
Support customization of timestamp format (v2 branch) (#399)
stanhu Apr 23, 2021
f6fb287
Fixed misleading comments in the interceptor file (#424)
iamrajiv May 27, 2021
cc20532
Switch from github.com/go-kit/kit to github.com/go-kit/log interfaces…
liggitt Jun 19, 2021
0c113ab
v2: Add support for the phuslog logging provider (#425)
ogimenezb Jun 19, 2021
27ca785
v2:providers/zap: fix caller annotation (#432)
jkawamoto Jul 2, 2021
028d350
added dependabot (#376)
iamrajiv Jul 6, 2021
5cdca41
Added a Copyright check in the Makefile (#420)
yashrsharma44 Jul 9, 2021
709d415
Cleanup v2 with some updates (#419)
yashrsharma44 Jul 10, 2021
49d9c0d
openmetrics: forward server context (#434)
Jul 10, 2021
dc87da6
recovery: change the default behavior (#439)
Jul 13, 2021
5b8ad84
Add all-validator support (#443)
leventeliu Jul 23, 2021
7d56e76
Remove backoffutils and added the files to retry package (#390)
yashrsharma44 Aug 3, 2021
274df59
v2:interceptors/logging: add payload decision to separate request res…
michaljemala Aug 7, 2021
f8899ff
Removed tags; Simplified interceptor code; Added logging fields edita…
bwplotka Aug 17, 2021
dd1540e
InterceptorTestSuite client connection optimize (#455)
HUSTtoKTH Aug 31, 2021
32bd5da
Remove opentracing from go.mod (#477)
jpkrohling Dec 2, 2021
ed43ab3
Replace two old Go versions with two new ones (#478)
jpkrohling Dec 3, 2021
a5b9e0b
Move util/metautils to root-level package metadata, fixes #392 (#474)
rahulkhairwar Dec 7, 2021
e4a6915
remove data race from zerolog provider (#487)
ecordell Mar 8, 2022
72478fa
Update provider/kit (#490)
metalmatze Apr 7, 2022
83835dc
Refactor tracing interceptor (#450)
XSAM Apr 25, 2022
58a4066
Add opentracing provider (#492)
XSAM May 5, 2022
5d0f5fe
update phuslog to fix typo (#499)
ogimenezb Jul 14, 2022
f3ab992
Added logr as logging Library provider (#510)
mcdoker18 Aug 30, 2022
001ba37
✨ new feat: selector middleware (#511)
aimuz Sep 7, 2022
cb54482
Add 1.18.x and 1.19.x unit tests (#513)
aimuz Sep 13, 2022
782d4b3
new doc: the format after gofmt (#512)
aimuz Sep 13, 2022
7ac0846
fix provider examples (#529)
forsaken628 Jan 12, 2023
e835172
docs: add `logging.InjectFields` usage description
aimuz Mar 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
recovery: change the default behavior (#439)
  • Loading branch information
Aliaksandr Mianzhynski authored Jul 13, 2021
commit dc87da6ded77b0ad012298232067456f08294f9f
21 changes: 16 additions & 5 deletions interceptors/recovery/interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ package recovery

import (
"context"
"fmt"
"runtime"

"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

// RecoveryHandlerFunc is a function that recovers from the panic `p` by returning an `error`.
Expand Down Expand Up @@ -50,8 +50,19 @@ func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor {
}

func recoverFrom(ctx context.Context, p interface{}, r RecoveryHandlerFuncContext) error {
if r == nil {
return status.Errorf(codes.Internal, "%s", p)
if r != nil {
return r(ctx, p)
}
return r(ctx, p)
stack := make([]byte, 64<<10)
stack = stack[:runtime.Stack(stack, false)]
return &PanicError{Panic: p, Stack: stack}
}

type PanicError struct {
Panic interface{}
Stack []byte
}

func (e *PanicError) Error() string {
return fmt.Sprintf("panic caught: %v\n\n%s", e.Panic, e.Stack)
}
10 changes: 6 additions & 4 deletions interceptors/recovery/interceptors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ func (s *RecoverySuite) TestUnary_SuccessfulRequest() {
func (s *RecoverySuite) TestUnary_PanickingRequest() {
_, err := s.Client.Ping(s.SimpleCtx(), &testpb.PingRequest{Value: "panic"})
require.Error(s.T(), err, "there must be an error")
assert.Equal(s.T(), codes.Internal, status.Code(err), "must error with internal")
assert.Equal(s.T(), "very bad thing happened", status.Convert(err).Message(), "must error with message")
assert.Equal(s.T(), codes.Unknown, status.Code(err), "must error with unknown")
assert.Contains(s.T(), status.Convert(err).Message(), "panic caught", "must error with message")
assert.Contains(s.T(), status.Convert(err).Message(), "recovery.recoverFrom", "must include stack trace")
}

func (s *RecoverySuite) TestStream_SuccessfulReceive() {
Expand All @@ -83,8 +84,9 @@ func (s *RecoverySuite) TestStream_PanickingReceive() {
require.NoError(s.T(), err, "should not fail on establishing the stream")
_, err = stream.Recv()
require.Error(s.T(), err, "there must be an error")
assert.Equal(s.T(), codes.Internal, status.Code(err), "must error with internal")
assert.Equal(s.T(), "very bad thing happened", status.Convert(err).Message(), "must error with message")
assert.Equal(s.T(), codes.Unknown, status.Code(err), "must error with unknown")
assert.Contains(s.T(), status.Convert(err).Message(), "panic caught", "must error with message")
assert.Contains(s.T(), status.Convert(err).Message(), "recovery.recoverFrom", "must include stack trace")
}

func TestRecoveryOverrideSuite(t *testing.T) {
Expand Down