diff --git a/changelog/unreleased/fix-disconnected-traces.md b/changelog/unreleased/fix-disconnected-traces.md new file mode 100644 index 0000000000..e924125ba5 --- /dev/null +++ b/changelog/unreleased/fix-disconnected-traces.md @@ -0,0 +1,5 @@ +Bugfix: Fix disconnected traces + +We fixed a problem where the appctx logger was using a new traceid instead of picking up the one from the trace parent. + +https://github.com/cs3org/reva/pull/4422 diff --git a/pkg/rgrpc/rgrpc.go b/pkg/rgrpc/rgrpc.go index 381c468c2d..4168c4f064 100644 --- a/pkg/rgrpc/rgrpc.go +++ b/pkg/rgrpc/rgrpc.go @@ -325,25 +325,24 @@ func (s *Server) getInterceptors(unprotected []string) ([]grpc.ServerOption, err return nil, errors.Wrap(err, "rgrpc: error creating unary auth interceptor") } - unaryInterceptors := []grpc.UnaryServerInterceptor{authUnary} - for _, t := range unaryTriples { - unaryInterceptors = append(unaryInterceptors, t.Interceptor) - s.log.Info().Msgf("rgrpc: chaining grpc unary interceptor %s with priority %d", t.Name, t.Priority) - } - - unaryInterceptors = append(unaryInterceptors, + unaryInterceptors := []grpc.UnaryServerInterceptor{ otelgrpc.UnaryServerInterceptor( otelgrpc.WithTracerProvider(s.tracerProvider), - otelgrpc.WithPropagators(rtrace.Propagator)), - ) - - unaryInterceptors = append([]grpc.UnaryServerInterceptor{ + otelgrpc.WithPropagators(rtrace.Propagator), + ), appctx.NewUnary(s.log, s.tracerProvider), token.NewUnary(), useragent.NewUnary(), log.NewUnary(), recovery.NewUnary(), - }, unaryInterceptors...) + authUnary, + } + + for _, t := range unaryTriples { + unaryInterceptors = append(unaryInterceptors, t.Interceptor) + s.log.Info().Msgf("rgrpc: chaining grpc unary interceptor %s with priority %d", t.Name, t.Priority) + } + unaryChain := grpc_middleware.ChainUnaryServer(unaryInterceptors...) streamTriples := []*streamInterceptorTriple{} @@ -372,20 +371,23 @@ func (s *Server) getInterceptors(unprotected []string) ([]grpc.ServerOption, err return nil, errors.Wrap(err, "rgrpc: error creating stream auth interceptor") } - streamInterceptors := []grpc.StreamServerInterceptor{authStream} - for _, t := range streamTriples { - streamInterceptors = append(streamInterceptors, t.Interceptor) - s.log.Info().Msgf("rgrpc: chaining grpc streaming interceptor %s with priority %d", t.Name, t.Priority) - } - - streamInterceptors = append([]grpc.StreamServerInterceptor{ - authStream, + streamInterceptors := []grpc.StreamServerInterceptor{ + otelgrpc.StreamServerInterceptor( + otelgrpc.WithTracerProvider(s.tracerProvider), + otelgrpc.WithPropagators(rtrace.Propagator), + ), appctx.NewStream(s.log, s.tracerProvider), token.NewStream(), useragent.NewStream(), log.NewStream(), recovery.NewStream(), - }, streamInterceptors...) + authStream, + } + + for _, t := range streamTriples { + streamInterceptors = append(streamInterceptors, t.Interceptor) + s.log.Info().Msgf("rgrpc: chaining grpc streaming interceptor %s with priority %d", t.Name, t.Priority) + } streamChain := grpc_middleware.ChainStreamServer(streamInterceptors...) opts := []grpc.ServerOption{