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

Method streamInterceptor

stats/opentelemetry/server_metrics.go:154–171  ·  view source on GitHub ↗
(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler)

Source from the content-addressed store, hash-verified

152}
153
154func (h *serverMetricsHandler) streamInterceptor(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
155 var metadataExchangeLabels metadata.MD
156 if h.options.MetricsOptions.pluginOption != nil {
157 metadataExchangeLabels = h.options.MetricsOptions.pluginOption.GetMetadata()
158 }
159 als := &attachLabelsStream{
160 ServerStream: ss,
161 metadataExchangeLabels: metadataExchangeLabels,
162 }
163 err := handler(srv, als)
164
165 // Add metadata exchange labels to trailers if never sent in headers,
166 // irrespective of whether or not RPC failed.
167 if !als.attachedLabels.Load() {
168 als.SetTrailer(als.metadataExchangeLabels)
169 }
170 return err
171}
172
173// TagConn exists to satisfy stats.Handler.
174func (h *serverMetricsHandler) TagConn(ctx context.Context, _ *stats.ConnTagInfo) context.Context {

Callers

nothing calls this directly

Calls 3

GetMetadataMethod · 0.65
SetTrailerMethod · 0.65
LoadMethod · 0.45

Tested by

no test coverage detected