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

Method streamInterceptor

stats/opencensus/opencensus.go:130–142  ·  view source on GitHub ↗

streamInterceptor handles per RPC context management. It also handles per RPC tracing and stats by creating a top level call span and recording the latency for the full RPC call.

(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption)

Source from the content-addressed store, hash-verified

128// tracing and stats by creating a top level call span and recording the latency
129// for the full RPC call.
130func (csh *clientStatsHandler) streamInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
131 startTime := time.Now()
132 ctx, span := csh.createCallSpan(ctx, method)
133 callback := func(err error) {
134 perCallTracesAndMetrics(err, span, startTime, method)
135 }
136 opts = append([]grpc.CallOption{grpc.OnFinish(callback)}, opts...)
137 s, err := streamer(ctx, desc, cc, method, opts...)
138 if err != nil {
139 return nil, err
140 }
141 return s, nil
142}
143
144type rpcInfo struct {
145 mi *metricsInfo

Callers

nothing calls this directly

Calls 4

createCallSpanMethod · 0.95
OnFinishFunction · 0.92
perCallTracesAndMetricsFunction · 0.85
NowMethod · 0.80

Tested by

no test coverage detected