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

[Tracing Redesign][2/N] Implement tracing unary Interceptors #2304

Open
wants to merge 10 commits into
base: dev-tracing-fix
Choose a base branch
from

Conversation

kexiongliu123
Copy link

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.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

internal/tracinginterceptor/tagshelper.go Outdated Show resolved Hide resolved
internal/tracinginterceptor/tagshelper.go Outdated Show resolved Hide resolved
internal/tracinginterceptor/tagshelper.go Outdated Show resolved Hide resolved
transport/tchannel/channel_transport.go Outdated Show resolved Hide resolved
internal/interceptor/inbound.go Outdated Show resolved Hide resolved
internal/tracinginterceptor/interceptor.go Outdated Show resolved Hide resolved
internal/tracinginterceptor/interceptor_test.go Outdated Show resolved Hide resolved
internal/tracinginterceptor/interceptor.go Show resolved Hide resolved
api/transport/propagation.go Outdated Show resolved Hide resolved
internal/tracinginterceptor/interceptor.go Show resolved Hide resolved
internal/tracinginterceptor/interceptor.go Outdated Show resolved Hide resolved
internal/tracinginterceptor/interceptor.go Outdated Show resolved Hide resolved
internal/tracinginterceptor/interceptor.go Outdated Show resolved Hide resolved
internal/tracinginterceptor/interceptor.go Outdated Show resolved Hide resolved
internal/tracinginterceptor/interceptor.go Outdated Show resolved Hide resolved
internal/tracinginterceptor/interceptor.go Outdated Show resolved Hide resolved
internal/tracinginterceptor/interceptor.go Outdated Show resolved Hide resolved
)

// PropagationCarrier is an interface to combine both reader and writer interface
type PropagationCarrier interface {
Copy link
Contributor

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 {
Copy link
Contributor

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())
Copy link
Contributor

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)
Copy link
Contributor

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 {
Copy link
Contributor

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:

  1. We also want to get the applicationErrorMeta
  2. 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
}

Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants