Compare commits

..

1 Commits

Author SHA1 Message Date
0b29668fe5 wrap stream for tracing
Some checks failed
build / test (push) Failing after 1m48s
build / lint (push) Successful in 9m12s
codeql / analyze (go) (push) Failing after 7m32s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-05-06 00:28:56 +03:00

14
grpc.go
View File

@@ -51,6 +51,18 @@ type ServerReflection struct {
}
*/
type streamWrapper struct {
ctx context.Context
grpc.ServerStream
}
func (w *streamWrapper) Context() context.Context {
if w.ctx != nil {
return w.ctx
}
return w.ServerStream.Context()
}
type Server struct {
handlers map[string]server.Handler
srv *grpc.Server
@@ -206,6 +218,8 @@ func (g *Server) handler(srv interface{}, stream grpc.ServerStream) error {
),
)
stream = &streamWrapper{ctx, stream}
ts := time.Now()
g.opts.Meter.Counter(semconv.ServerRequestInflight, "endpoint", fullMethod).Inc()