From 071b1f4f2ad2c713530d75e3cf1c40abaf551421 Mon Sep 17 00:00:00 2001 From: Jay Mundrawala Date: Mon, 16 Sep 2024 03:32:30 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Capture=20underlying=20error=20o?= =?UTF-8?q?n=20codes.DataLoss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We are throwing away the underlying error. Capturing it to better understand why this happens --- server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server.go b/server.go index 3545c50..2ea0367 100644 --- a/server.go +++ b/server.go @@ -118,11 +118,12 @@ func (s *server) ServeHTTP(w http.ResponseWriter, req *http.Request) { // preProcessRequest is used to preprocess the incoming request. // It returns the context, a cancel function and the body of the request. The cancel function can be used to cancel // the context. It also adds the http headers to the context. -func preProcessRequest(ctx context.Context, req *http.Request) (context.Context, context.CancelFunc, []byte, error) { +func preProcessRequest(ctx context.Context, span trace.Span, req *http.Request) (context.Context, context.CancelFunc, []byte, error) { // read body content body, err := io.ReadAll(req.Body) defer req.Body.Close() if err != nil { + span.RecordError(err) return nil, nil, nil, status.Error(codes.DataLoss, "unrecoverable data loss or corruption") }