MCPcopy
hub / github.com/grpc/grpc-go / unaryInterceptor

Method unaryInterceptor

stats/opentelemetry/client_metrics.go:85–101  ·  view source on GitHub ↗
(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption)

Source from the content-addressed store, hash-verified

83}
84
85func (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...)
87
88 if h.options.MetricsOptions.pluginOption != nil {
89 md := h.options.MetricsOptions.pluginOption.GetMetadata()
90 for k, vs := range md {
91 for _, v := range vs {
92 ctx = metadata.AppendToOutgoingContext(ctx, k, v)
93 }
94 }
95 }
96
97 startTime := time.Now()
98 err := invoker(ctx, method, req, reply, cc, opts...)
99 h.perCallMetrics(ctx, err, startTime, ci)
100 return err
101}
102
103// determineMethod determines the method to record attributes with. This will be
104// "other" if StaticMethod isn't specified or if method filter is set and

Callers

nothing calls this directly

Calls 5

perCallMetricsMethod · 0.95
AppendToOutgoingContextFunction · 0.92
getOrCreateCallInfoFunction · 0.85
NowMethod · 0.80
GetMetadataMethod · 0.65

Tested by

no test coverage detected