func logResponseOutcome()

in loadgen/eventhandler/apm.go [82:105]


func logResponseOutcome(logger *zap.Logger, res *http.Response) {
	if res == nil {
		return
	}
	var body bytes.Buffer
	if _, err := body.ReadFrom(res.Body); err != nil {
		logger.Error("cannot read body", zap.Error(err))
	}

	destination := "unknown"
	if res.Request != nil {
		destination = res.Request.URL.String()
	}

	if res.StatusCode >= http.StatusBadRequest {
		logger.Error("request failed",
			zap.Int("status_code", res.StatusCode), zap.String("response", body.String()),
			zap.String("destination", destination))
	} else {
		logger.Debug("request completed",
			zap.Int("status_code", res.StatusCode), zap.String("response", body.String()),
			zap.String("destination", destination))
	}
}