-
Notifications
You must be signed in to change notification settings - Fork 295
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
fix issue 221: grpc error reporting #317
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,7 @@ func startTransaction(ctx context.Context, app *newrelic.Application, fullMethod | |
// https://github.com/newrelic/go-agent/blob/master/v3/integrations/nrgrpc/example/server/server.go | ||
// | ||
func UnaryServerInterceptor(app *newrelic.Application) grpc.UnaryServerInterceptor { | ||
if nil == app { | ||
if app == nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Love the new non-Yoda conditions! |
||
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { | ||
return handler(ctx, req) | ||
} | ||
|
@@ -82,6 +82,9 @@ func UnaryServerInterceptor(app *newrelic.Application) grpc.UnaryServerIntercept | |
ctx = newrelic.NewContext(ctx, txn) | ||
resp, err = handler(ctx, req) | ||
txn.SetWebResponse(nil).WriteHeader(int(status.Code(err))) | ||
if err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like the right thing to do! Do we have an example of this in the UI? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I'll add it to the original issue's conversation. |
||
txn.NoticeError(err) | ||
} | ||
return | ||
} | ||
} | ||
|
@@ -130,7 +133,7 @@ func newWrappedServerStream(stream grpc.ServerStream, txn *newrelic.Transaction) | |
// https://github.com/newrelic/go-agent/blob/master/v3/integrations/nrgrpc/example/server/server.go | ||
// | ||
func StreamServerInterceptor(app *newrelic.Application) grpc.StreamServerInterceptor { | ||
if nil == app { | ||
if app == nil { | ||
return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { | ||
return handler(srv, ss) | ||
} | ||
|
@@ -142,6 +145,9 @@ func StreamServerInterceptor(app *newrelic.Application) grpc.StreamServerInterce | |
|
||
err := handler(srv, newWrappedServerStream(ss, txn)) | ||
txn.SetWebResponse(nil).WriteHeader(int(status.Code(err))) | ||
if err != nil { | ||
txn.NoticeError(err) | ||
} | ||
return err | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we should remove or change this comment.