Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back missing fields in server logs and remove double log #409

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading