Avoid dumping request headers in router (#2122)
Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -705,16 +705,17 @@ func (fh functionHandler) getProxyErrorHandler(start time.Time, rrt *RetryingRou
|
|||||||
// Reference: https://httpstatuses.com/499
|
// Reference: https://httpstatuses.com/499
|
||||||
status = 499
|
status = 499
|
||||||
msg = "client closes the connection"
|
msg = "client closes the connection"
|
||||||
fh.logger.Debug(msg, zap.Any("function", fh.function), zap.Any("request_header", req.Header))
|
fh.logger.Debug(msg, zap.Any("function", fh.function), zap.String("status", "Client Closed Request"))
|
||||||
case context.DeadlineExceeded:
|
case context.DeadlineExceeded:
|
||||||
status = http.StatusGatewayTimeout
|
status = http.StatusGatewayTimeout
|
||||||
msg := "function not responses before the timeout"
|
msg := "no response from function before timeout"
|
||||||
fh.logger.Error(msg, zap.Any("function", fh.function), zap.Any("request_header", req.Header))
|
fh.logger.Error(msg, zap.Any("function", fh.function), zap.String("status", http.StatusText(status)))
|
||||||
default:
|
default:
|
||||||
code, _ := ferror.GetHTTPError(err)
|
code, _ := ferror.GetHTTPError(err)
|
||||||
status = code
|
status = code
|
||||||
msg = "error sending request to function"
|
msg = "error sending request to function"
|
||||||
fh.logger.Error(msg, zap.Error(err), zap.Any("function", fh.function), zap.Any("request_header", req.Header), zap.Any("code", code))
|
fh.logger.Error(msg, zap.Error(err), zap.Any("function", fh.function),
|
||||||
|
zap.Any("status", http.StatusText(status)), zap.Int("code", code))
|
||||||
}
|
}
|
||||||
|
|
||||||
go fh.collectFunctionMetric(start, rrt, req, &http.Response{
|
go fh.collectFunctionMetric(start, rrt, req, &http.Response{
|
||||||
@@ -730,7 +731,6 @@ func (fh functionHandler) getProxyErrorHandler(start time.Time, rrt *RetryingRou
|
|||||||
"error writing HTTP response",
|
"error writing HTTP response",
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
zap.Any("function", fh.function),
|
zap.Any("function", fh.function),
|
||||||
zap.Any("request_header", req.Header),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -93,8 +94,11 @@ func serve(ctx context.Context, logger *zap.Logger, port int, tracingSamplingRat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if displayAccessLog {
|
if displayAccessLog {
|
||||||
logger.Info("path", zap.String("path", r.URL.Path),
|
reqMsg, err := httputil.DumpRequest(r, false)
|
||||||
zap.String("method", r.Method), zap.Any("header", r.Header))
|
if err != nil {
|
||||||
|
logger.Error("error dumping request", zap.Error(err))
|
||||||
|
}
|
||||||
|
logger.Info("request dump", zap.String("request", string(reqMsg)))
|
||||||
}
|
}
|
||||||
return trace.StartOptions{
|
return trace.StartOptions{
|
||||||
Sampler: trace.ProbabilitySampler(tracingSamplingRate),
|
Sampler: trace.ProbabilitySampler(tracingSamplingRate),
|
||||||
|
|||||||
Reference in New Issue
Block a user