getOrCreateCallInfo returns the existing callInfo from context if present, or creates and attaches a new one.
(ctx context.Context, cc *grpc.ClientConn, method string, opts ...grpc.CallOption)
| 71 | // getOrCreateCallInfo returns the existing callInfo from context if present, |
| 72 | // or creates and attaches a new one. |
| 73 | func getOrCreateCallInfo(ctx context.Context, cc *grpc.ClientConn, method string, opts ...grpc.CallOption) (context.Context, *callInfo) { |
| 74 | ci := getCallInfo(ctx) |
| 75 | if ci == nil { |
| 76 | ci = &callInfo{ |
| 77 | target: cc.CanonicalTarget(), |
| 78 | method: determineMethod(method, opts...), |
| 79 | } |
| 80 | ctx = context.WithValue(ctx, callInfoKey{}, ci) |
| 81 | } |
| 82 | return ctx, ci |
| 83 | } |
| 84 | |
| 85 | func (h *clientMetricsHandler) unaryInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { |
| 86 | ctx, ci := getOrCreateCallInfo(ctx, cc, method, opts...) |
no test coverage detected