Skip to content

Commit

Permalink
Merge pull request #4422 from aduffeck/fix-disconnected-traces
Browse files Browse the repository at this point in the history
Fix interceptor order to make sure tracing is set up first
  • Loading branch information
aduffeck authored Dec 19, 2023
2 parents da04bc3 + 412c5a6 commit 6e8505c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-disconnected-traces.md
Original file line number Diff line number Diff line change
@@ -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
44 changes: 23 additions & 21 deletions pkg/rgrpc/rgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 6e8505c

Please sign in to comment.