-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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: show example of tracing over http->grpc boundary #348
Comments
Is here any news? Any examples,docs will be appreciated |
I believe the stackdriver trace works with grpc-gateway. |
@uschen If I understood correctly, stackdriver works in google cloud and AWS only. I want to use tracing in own solution. |
@maxkondr you can use stackdriver trace if your workloads aren't in google's cloud. |
Any examples or docs for supporting opentracing? Thanks! |
similar to how I solved #7 - I ended up wrapping the mux and writing a little bit of code to propagate the tracing context correctly. here's how I did it:
|
there is a ready for use solution from github.com/opentracing-contrib/go-stdlib/nethttp lib:
|
Not sure if this is the right place to ask questions, but I didn't know where else to post. Does the gRPC Gateway client need to be initiated with a tracing interceptor? I struggled to get @theRealWardo's example to work until I added a client-side interceptor. If so, I think it would be helpful to bring this up in the documentation (happy to open a PR for this). There's some relevant information here, but I wanted to double check. |
Hi @ZachEddy, we'd happily welcome any documentation improvements you could contribute. I haven't got any experience with this myself so your knowledge would be very good to capture. |
Sounds good! Some additional documentation would be useful, but I like the original suggestion to add tracing support out of the box. Maybe this can be accomplished by adding another Something like |
Hi. @johanbrandhorst asked me to write how I have forwarded span from gateway -> grpc server. Well after a few hours of debugging this is my final code. For tracing in gateway I have used Implementation of nethttp: func NewTracedRuntimeMuxServer(tracer opentracing.Tracer, mux *runtime.ServeMux) *http.Server {
return &http.Server{
Handler: nethttp.Middleware(
tracer,
mux,
nethttp.OperationNameFunc(func(r *http.Request) string {
return fmt.Sprintf("HTTP-gRPC %s %s", r.Method, r.URL.String())
}),
),
}
} Custom metadata from span function: func MetadataFromSpan(span opentracing.Span) metadata.MD {
ctx := span.Context()
carrier := make(map[string]string)
span.Tracer().Inject(
ctx,
opentracing.TextMap,
opentracing.TextMapCarrier(carrier),
)
return metadata.New(carrier)
} Implementation of the custom metadata from span function: mux := runtime.NewServeMux(
runtime.WithMetadata(
func(ctx context.Context, r *http.Request) metadata.MD {
span := opentracing.SpanFromContext(ctx)
tracing.MetadataFromSpan(span)
return tracing.MetadataFromSpan(span)
},
),
) Getting the values in gRPC is done via this package |
We should show how to propagate an incoming traced http request over the grpc boundary.
Further, perhaps this just be supported out of the box.
The text was updated successfully, but these errors were encountered: