Skip to content

Commit

Permalink
Add back missing fields in server logs and remove double log (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheukt authored Jan 24, 2025
1 parent 332545c commit ac7a6ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
5 changes: 2 additions & 3 deletions rpc/server_interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
grpc_logging "github.com/grpc-ecosystem/go-grpc-middleware/logging"
"github.com/pkg/errors"
"go.opencensus.io/trace"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -157,7 +156,7 @@ func serverCallFields(ctx context.Context, fullMethodString string, start time.T
var f []any
f = append(f, "grpc.start_time", start.UTC().Format(iso8601))
if d, ok := ctx.Deadline(); ok {
f = append(f, zap.String("grpc.request.deadline", d.UTC().Format(iso8601)))
f = append(f, "grpc.request.deadline", d.UTC().Format(iso8601))
}
service := path.Dir(fullMethodString)[1:]
method := path.Base(fullMethodString)
Expand All @@ -166,5 +165,5 @@ func serverCallFields(ctx context.Context, fullMethodString string, start time.T
"system", "grpc",
"grpc.service", service,
"grpc.method", method,
})
}...)
}
21 changes: 4 additions & 17 deletions rpc/wrtc_server_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,6 @@ func (s *webrtcServerStream) onRequest(request *webrtcpb.Request) {
}
}

func isContextCanceled(err error) bool {
if err == nil {
return false
}
if utils.FilterOutError(err, context.Canceled) == nil {
return true
}
gStatus, isGRPCErr := status.FromError(err)
return isGRPCErr && gStatus.Code() == codes.Canceled
}

func (s *webrtcServerStream) processHeaders(headers *webrtcpb.RequestHeaders) {
s.logger = utils.AddFieldsToLogger(s.logger, "method", headers.GetMethod())
s.logger.Debug("incoming grpc request")
Expand Down Expand Up @@ -295,12 +284,10 @@ func (s *webrtcServerStream) processHeaders(headers *webrtcpb.RequestHeaders) {
s.ch.server.processHeadersWorkers.Done()
<-s.ch.server.callTickets // return a ticket
}()
if err := handlerFunc(s); err != nil {
if errors.Is(err, io.ErrClosedPipe) || isContextCanceled(err) {
return
}
s.logger.Errorw("error calling handler", "error", err)
}
// we're not checking/logging the error here because it is handled
// by [rpc.grpcUnaryServerInterceptor] and [rpc.grpcStreamServerInterceptor].
//nolint:errcheck,gosec
handlerFunc(s)
})
}

Expand Down

0 comments on commit ac7a6ac

Please sign in to comment.