func (pi *activeRequestsIndex) ScanEntries(requestId string, limit int64, cons datastore.ScanConsistency,
	vector timestamp.Vector, conn *datastore.IndexConnection) {
	defer close(conn.EntryChannel())
	numRequests, err := server.ActiveRequestsCount()
	if err != nil {
		conn.Error(err)
		return
	}
	requestIds := make([]string, numRequests)
	server.ActiveRequestsForEach(func(id string, request server.Request) {
		requestIds = append(requestIds, id)
	})

	for _, name := range requestIds {
		entry := datastore.IndexEntry{PrimaryKey: name}
		conn.EntryChannel() <- &entry
	}
}
func (b *activeRequestsKeyspace) Count() (int64, errors.Error) {
	c, err := server.ActiveRequestsCount()
	return int64(c), err
}
Example #3
0
func (g *gometricsAccountingStore) Vitals() (interface{}, errors.Error) {
	var mem runtime.MemStats

	runtime.ReadMemStats(&mem)
	request_timer := g.registry.Timer(accounting.REQUEST_TIMER)
	request_rate := g.registry.Meter(accounting.REQUEST_RATE)
	prepared := g.registry.Meter(accounting.PREPARED)

	now := time.Now()
	newUtime, newStime := util.CpuTimes()

	g.Lock()
	uptime := now.Sub(g.vitals["startTime"].(time.Time))
	dur := float64(now.Sub(g.vitals["lastNow"].(time.Time)))
	uPerc := float64(newUtime-g.vitals["lastUtime"].(int64)) / dur
	sPerc := float64(newStime-g.vitals["lastStime"].(int64)) / dur
	pausePerc := float64(mem.PauseTotalNs-g.vitals["lastPauseTime"].(uint64)) / dur

	g.vitals["lastNow"] = now
	g.vitals["lastUtime"] = newUtime
	g.vitals["lastStime"] = newStime
	g.vitals["lastPauseTime"] = mem.PauseTotalNs
	g.Unlock()

	actCount, _ := server.ActiveRequestsCount()
	totCount := request_rate.Count()
	var prepPercent float64
	if totCount > 0 {
		prepPercent = float64(prepared.Count()) / float64(totCount)
	} else {
		prepPercent = 0.0
	}

	return VitalsRecord{
		Uptime:         uptime.String(),
		LocalTime:      now.String(),
		Version:        util.VERSION,
		TotThreads:     runtime.NumGoroutine(),
		Cores:          runtime.GOMAXPROCS(0),
		GCNum:          mem.NextGC,
		GCPauseTime:    time.Duration(mem.PauseTotalNs).String(),
		GCPausePercent: util.RoundPlaces(pausePerc, 4),
		MemoryUsage:    mem.Alloc,
		MemoryTotal:    mem.TotalAlloc,
		MemorySys:      mem.Sys,
		CPUUser:        util.RoundPlaces(uPerc, 4),
		CPUSys:         util.RoundPlaces(sPerc, 4),
		ReqCount:       totCount,
		ActCount:       int64(actCount),
		Req1min:        util.RoundPlaces(request_rate.Rate1(), 4),
		Req5min:        util.RoundPlaces(request_rate.Rate5(), 4),
		Req15min:       util.RoundPlaces(request_rate.Rate15(), 4),
		ReqMean:        time.Duration(request_timer.Mean()).String(),
		ReqMedian:      time.Duration(request_timer.Percentile(.5)).String(),
		Req80:          time.Duration(request_timer.Percentile(.8)).String(),
		Req95:          time.Duration(request_timer.Percentile(.95)).String(),
		Req99:          time.Duration(request_timer.Percentile(.99)).String(),
		Prepared:       prepPercent,
	}, nil

}