(smp ServerMetricsProvider)
| 136 | } |
| 137 | |
| 138 | func unaryInt(smp ServerMetricsProvider) func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { |
| 139 | return func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { |
| 140 | // We don't allocate the metric recorder here. It will be allocated the |
| 141 | // first time the user calls CallMetricsRecorderFromContext(). |
| 142 | rw := &recorderWrapper{smp: smp} |
| 143 | ctxWithRecorder := newContextWithRecorderWrapper(ctx, rw) |
| 144 | |
| 145 | resp, err := handler(ctxWithRecorder, req) |
| 146 | |
| 147 | // It is safe to access the underlying metric recorder inside the wrapper at |
| 148 | // this point, as the user's RPC handler is done executing, and therefore |
| 149 | // there will be no more calls to CallMetricsRecorderFromContext(), which is |
| 150 | // where the metric recorder is lazy allocated. |
| 151 | if rw.r != nil { |
| 152 | rw.setTrailerMetadata(ctx) |
| 153 | } |
| 154 | return resp, err |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | func streamInt(smp ServerMetricsProvider) func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { |
| 159 | return func(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error { |
no test coverage detected