Skip to content

Commit

Permalink
Merge pull request #55 from Comcast/feature/moreLogging
Browse files Browse the repository at this point in the history
transaction ID, latency unit to ms
  • Loading branch information
schmidtw authored Jan 30, 2018
2 parents aad8e3c + b4add12 commit 4d39e24
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/tr1d1um/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (ch *ConversionHandler) ServeHTTP(origin http.ResponseWriter, req *http.Req

tr1d1umResp := tr1Resp.(*Tr1d1umResponse)

bookkeepingLog(ch, tr1d1umResp, req, time.Now().Sub(requestArrivalTime).Seconds())
bookkeepingLog(ch, tr1d1umResp, req, time.Now().Sub(requestArrivalTime), wrpMsg.TransactionUUID)
TransferResponse(tr1d1umResp, origin)
}

Expand Down Expand Up @@ -161,7 +161,7 @@ func (ch *ConversionHandler) HandleStat(origin http.ResponseWriter, req *http.Re
origin.Header().Set(contentTypeKey, wrp.JSON.ContentType())
tr1d1umResp := tr1Resp.(*Tr1d1umResponse)

bookkeepingLog(ch, tr1d1umResp, req, time.Now().Sub(requestArrivalTime).Seconds())
bookkeepingLog(ch, tr1d1umResp, req, time.Now().Sub(requestArrivalTime), GetOrGenTID(req.Header))

TransferResponse(tr1d1umResp, origin)
}
Expand Down Expand Up @@ -251,7 +251,7 @@ func TransferResponse(from *Tr1d1umResponse, to http.ResponseWriter) {
}

//helper function that logs desired HTTP request/response info
func bookkeepingLog(logger log.Logger, tr1Resp *Tr1d1umResponse, req *http.Request, latency float64) {
func bookkeepingLog(logger log.Logger, tr1Resp *Tr1d1umResponse, req *http.Request, latency time.Duration, TID string) {
logging.Info(logger).Log(
logging.MessageKey(), "Bookkeeping response",
"requestAddress", req.RemoteAddr,
Expand All @@ -260,5 +260,6 @@ func bookkeepingLog(logger log.Logger, tr1Resp *Tr1d1umResponse, req *http.Reque
"responseHeaders", tr1Resp.Headers,
"responseCode", tr1Resp.Code,
"responseError", tr1Resp.err,
"latencySeconds", latency)
"latency", latency,
"tid", TID)
}

0 comments on commit 4d39e24

Please sign in to comment.