go-agent icon indicating copy to clipboard operation
go-agent copied to clipboard

v3/integrations/nrgrpc: Unary Interceptor doesn't extract any error details

Open eightnoteight opened this issue 3 years ago • 3 comments

Currently when an error is returned in a grpc call, the stack trace reported comes from the newrelic library interceptor stage, rather than extracting the stack trace from the error.

Description

I believe during the reporting stage of an error, this piece of code only extracts grpc status code from the error but ignores all the rich contextual information inside the error like stack trace. since the error interceptor here no longer has access to the original error value, it falls back to simply forwarding just error message to the newrelic.

Steps to Reproduce

Simulate an error response from grpc handler in the example but add stack trace to the error by using github.com/pkg/errors

Expected Behavior

newrelic ui showing the stack trace thats inside the error value.

NR Diag results

image

eightnoteight avatar Nov 13 '21 17:11 eightnoteight

Hi @eightnoteight , you make a good point! We'll look to make sure we can put a more useful stack trace into those gRPC errors and bring it to the attention of our Product Manager.

RichVanderwal avatar Dec 14 '21 23:12 RichVanderwal

I realize your stackTracer and errors package's (https://github.com/pkg/errors) stackTracker is not the same. That's why new relic notify default stack trace: Here is yours

type stackTracer interface {
	StackTrace() []uintptr
}

Here is errors package's

type stackTracer interface {
	StackTrace() errors.StackTrace
}

@RichVanderwal please help to solve it, thanks!

austinphan avatar Dec 30 '21 05:12 austinphan

Additional issue, the method

type ErrorHandler func(context.Context, *newrelic.Transaction, *status.Status)

allow only gRPC status pass to it, the handler is called from reportInterceptorStatus, error will be converted to gRPC status grpcStatus := status.Convert(err). With the design of ErrorHandler, there is no way to get the stack traces from the original error in case handler is ErrorInterceptorStatusHandler (which call txn.NoticeError to report error details) Please help to improve the flow here

austinphan avatar Dec 30 '21 07:12 austinphan