-
Notifications
You must be signed in to change notification settings - Fork 103
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
[Tracing Redesign][2/N] Implement tracing unary Interceptors #2304
base: dev-tracing-fix
Are you sure you want to change the base?
Conversation
|
) | ||
|
||
// PropagationCarrier is an interface to combine both reader and writer interface | ||
type PropagationCarrier interface { |
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.
it seems there is not much value to define a new interface here.
We can just use the original two interfaces for interface compliance check:
var _ opentracing.TextMapReader = HeadersCarrier{}
var _ opentracing.TextMapWriter = HeadersCarrier{}
// GetPropagationFormat returns the opentracing propagation depends on transport. | ||
// For TChannel, the format is opentracing.TextMap | ||
// For HTTP and gRPC, the format is opentracing.HTTPHeaders | ||
func GetPropagationFormat(transport string) opentracing.BuiltinFormat { |
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.
Nit: since we move those propagation related funcs to the same package, there is no need to make them exported.
status := yarpcerrors.FromError(err) | ||
if status != nil { | ||
errCode := status.Code() | ||
span.SetTag("rpc.yarpc.status_code", errCode.String()) |
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.
Don't we want to use the integer value for rpc.yarpc.status_code
tag?
} | ||
|
||
ext.Error.Set(span, true) | ||
status := yarpcerrors.FromError(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.
nit: more concise below since status is not used anywhere else
if status := yarpcerrors.FromError(err); status != nil {
}
defer span.Finish() | ||
|
||
err := h.Handle(ctx, req, resw) | ||
if appErrSetter, ok := resw.(interface{ IsApplicationError() bool }); ok { |
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.
The writer wrapper is probably still the right way to go with, the reasons are:
- We also want to get the
applicationErrorMeta
- For the case where yarpc dispatcher is not used (hence obs middleware is not used), the original writer doesn't have
IsApplicationError()
method at all.
span.SetTag("error.type", "application_error") | ||
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.
Could we also check the ApplicationErrorMeta
as well to add more error details?
This PR introduces the unary interceptors in YARPC Go to improve the structure and functionality of tracing and middleware handling. The primary focus is on separating the unary interceptors to allow for specialized optimizations and cleaner handling of tracing operations.
Key Changes:
Introduced a dedicated UnaryInbound and UnaryOutbound middleware architecture, simplifying the tracing logic for unary requests.
Introduced inbound.go and outbound.go files to reflect the specialized unary middleware design, improving maintainability and reducing complexity.
Enhanced test coverage for the unary path, ensuring that all middleware logic is properly unit tested with specific focus on the flow of unary RPCs.
Updated helper methods for extracting and applying tracing tags to unary requests, ensuring clearer separation of concerns.