HTTPGRPCTracingInterceptor adds additional information about the encapsulated HTTP request to httpgrpc trace spans. The httpgrpc client wraps HTTP requests up into a generic httpgrpc.HTTP/Handle gRPC method. The httpgrpc server unwraps httpgrpc.HTTP/Handle gRPC requests into HTTP requests and forwa
(router *mux.Router)
| 185 | // span tags to whatever parent span is active in the caller, rather than the /httpgrpc.HTTP/Handle |
| 186 | // span created by the tracing middleware for requests that arrive over the network. |
| 187 | func HTTPGRPCTracingInterceptor(router *mux.Router) grpc.UnaryServerInterceptor { |
| 188 | return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { |
| 189 | if info.FullMethod != "/httpgrpc.HTTP/Handle" { |
| 190 | return handler(ctx, req) |
| 191 | } |
| 192 | |
| 193 | httpgrpcRequest, ok := req.(*httpgrpc.HTTPRequest) |
| 194 | if !ok { |
| 195 | return handler(ctx, req) |
| 196 | } |
| 197 | |
| 198 | httpRequest, err := httpgrpc.ToHTTPRequest(ctx, httpgrpcRequest) |
| 199 | if err != nil { |
| 200 | return handler(ctx, req) |
| 201 | } |
| 202 | |
| 203 | if opentracing.IsGlobalTracerRegistered() { |
| 204 | return handleHTTPGRPCRequestWithOpenTracing(ctx, req, httpRequest, router, handler) |
| 205 | } |
| 206 | |
| 207 | return handleHTTPGRPCRequestWithOTel(ctx, req, httpRequest, router, handler) |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | func handleHTTPGRPCRequestWithOpenTracing(ctx context.Context, req any, httpRequest *http.Request, router *mux.Router, handler grpc.UnaryHandler) (any, error) { |
| 212 | tracer := opentracing.GlobalTracer() |
no test coverage detected