Skip to content

Commit

Permalink
Add in time logs to track down slowness
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaley committed Sep 28, 2016
1 parent d2fbcf6 commit 9fe3d14
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rackhd/proxy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net"
"net/http"
"sync"
"time"

regStore "github.com/RackHD/neighborhood-manager/libreg/registry"
"github.com/RackHD/neighborhood-manager/libreg/registry/consul"
Expand Down Expand Up @@ -57,6 +58,7 @@ func (p *Server) HandleTest(w http.ResponseWriter, r *http.Request) {
// HandleNodes sends, recieves, and processes all the data
func (p *Server) HandleNodes(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
fmt.Printf("Request Recieved => %s\n", time.Now())
addrMap, err := p.GetAddresses(w, r)
if len(addrMap) == 0 {
w.WriteHeader(200)
Expand All @@ -70,7 +72,7 @@ func (p *Server) HandleNodes(w http.ResponseWriter, r *http.Request) {
}
if (r.Method != "GET") && (len(addrMap) > 1) {
w.WriteHeader(400)
w.Write([]byte(fmt.Sprintln("Unsupported api call to multiple hosts. Use query string method.")))
w.Write([]byte(fmt.Sprintln("Unsupported api call to multiple hosts. Use query string method."))) //TODO make this json
return
}
ar := p.GetResp(r, addrMap)
Expand All @@ -93,7 +95,7 @@ func (p *Server) GetResp(r *http.Request, addrs map[string]struct{}) Responses {
}
client := cleanhttp.DefaultClient()
respGet, err := client.Do(req)
fmt.Println("request sent")
fmt.Printf("Request Sent => %s\n", time.Now())
if err != nil {
cr <- NewResponseFromError(err)
return
Expand Down Expand Up @@ -194,4 +196,5 @@ func (p *Server) RespCheck(r *http.Request, w http.ResponseWriter, ar Responses)
}
w.Write([]byte("]"))
w.WriteHeader(status)
fmt.Printf("Response Written => %s\n", time.Now())
}

0 comments on commit 9fe3d14

Please sign in to comment.