func doCompletedRequests(endpoint *HttpEndpoint, w http.ResponseWriter, req *http.Request) (interface{}, errors.Error) { numRequests := accounting.RequestsCount() requests := make([]map[string]interface{}, numRequests) i := 0 snapshot := func(requestId string, request *accounting.RequestLogEntry) { // FIXME quick hack to avoid overruns if i >= numRequests { return } requests[i] = map[string]interface{}{} requests[i]["requestId"] = request.RequestId if request.Statement != "" { requests[i]["statement"] = request.Statement } if request.PreparedName != "" { requests[i]["preparedName"] = request.PreparedName requests[i]["preparedText"] = request.PreparedText } requests[i]["requestTime"] = request.Time requests[i]["elapsedTime"] = request.ElapsedTime requests[i]["serviceTime"] = request.ServiceTime requests[i]["resultCount"] = request.ResultCount requests[i]["resultSize"] = request.ResultSize requests[i]["errorCount"] = request.ErrorCount requests[i]["sortCount"] = request.SortCount // FIXME more stats i++ } accounting.RequestsForeach(snapshot) return requests, nil }
func (b *requestLogKeyspace) Count() (int64, errors.Error) { return int64(accounting.RequestsCount()), nil }