Merge pull request #38 from navi-medici/DE-3247

DE-3247 | updated logging for failing requests
This commit is contained in:
Purushotham Pururava Pushpavanth
2024-08-26 14:35:28 +05:30
committed by GitHub
2 changed files with 10 additions and 2 deletions

View File

@@ -66,7 +66,10 @@ func (wp *WorkerPool) processRequest(request RequestObject) {
var result map[string]interface{}
if err := json.Unmarshal(messageBytes, &result); err != nil {
wp.logger.Error("Failed to unmarshal JSON", zap.Error(err))
wp.logger.Error("Failed to unmarshal JSON",
zap.Error(err),
zap.String("messageBytes", string(messageBytes)),
zap.Int("bytesLength", len(messageBytes)))
return
}

View File

@@ -70,7 +70,12 @@ func eventsHandlerJson(workerPool *lib.WorkerPool) http.HandlerFunc {
body, err := ioutil.ReadAll(reader) // todo Limit to 1MB
if err != nil {
logger.Error("Error reading request body", zap.Error(err))
logger.Error("Error reading request body",
zap.Error(err),
zap.String("remote_addr", r.RemoteAddr),
zap.String("user_agent", r.UserAgent()),
zap.Int64("content_length", r.ContentLength),
)
http.Error(w, "Request body invalid", http.StatusBadRequest)
metrics.EventHandlerTimeHist.WithLabelValues(JSON, ERROR).Observe(float64(utils.NanosToMillis(time.Now().UnixNano()) - eventHandlerStartTime))
return